My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum


Reply
 
LinkBack Thread Tools Display Modes
February 23rd, 2012, 07:07 AM   #1
Newbie
 
Joined: Oct 2011

Posts: 22
Thanks: 0

Grammars

Does anyone have like a "dummies" kind of guide on how to construct context-free grammars and regular grammars. I get the two confused and I find myself struggling coming up with them. The things I do know is the format: Grammar = { variables, alphabet, production rules, Start symbol}

It just seems daunting when writing them. Like how you know when to place a variable (capital letter) in the rule and how you know what letters go in what rule. I do understand that you're trying to produce the grammar which take on these production rules.

I really need to clear the dust that is these two subjects. So if you cite any good sources or explain slowly in words here that is understandable on an elementary level, thank you so much!!
eulerrules1 is offline  
 
March 13th, 2012, 10:42 AM   #2
Member
 
Joined: Sep 2010

Posts: 63
Thanks: 0

Re: Grammars

From the little bit of reading Iíve done on parsing, I think you would start with the most general expression and break it down to its alternatives. So for instance an expression can be a sum or product of terms. A term, will either be a constant, a bracketed expression, or a product of terms.

You create rules like this and the parsers recursively processes them until you have no non terminating symbols.

That said, while the parser works from the top down, with complex languages like English it helps to think about things from the bottom up. Natural language is of course not completely context free but there are some general rules. Like at the bottom we have such things as verbs, nouns , adverbs, adjectives and propositions, identifiers (a, an, the). Then we combine nouns with such things as identifiers and adjectives to get noun phrases. We can combine verbs with noun phrases to create verb phrases and use prepositions or conjunctions to combine phrases into sentences.

We could do some simple sentence parsing, treating English as a context free grammar but we wonít always be successful and will lose some meaning. So a simple sentence parser might start with something like a sentence is either a phrase, two phrases joined by a sentence connector such as a conjunction or preposition. A phrase is either a noun phrase or a verb phrase.

This is of course a really simple treatment. May I ask what you wish to use this grammar for?
John Creighton is offline  
September 11th, 2019, 11:07 AM   #3
Newbie
 
Joined: Sep 2019
From: Slovakia

Posts: 3
Thanks: 0

Some ways of grammar construction

There are several ways for constructing a grammar. One of them is setting rules for grouping signs of the alphabet into the words. Another way is a network graph, where the edges, but not necessarily, can represent the signs of the alphabet.
vlado77 is offline  
September 11th, 2019, 11:33 AM   #4
Newbie
 
Joined: Sep 2019
From: Slovakia

Posts: 3
Thanks: 0

Some ways of grammar construction

There are several ways of grammar construction. One of them is defining the rules of grouping the elements of the alphabet into the words. Another way is the network graph, where the elements can be assigned to the edges, although not necessarily to them.
vlado77 is offline  
Reply

  My Math Forum > Science Forums > Computer Science

Tags
grammars



Thread Tools
Display Modes






Copyright © 2019 My Math Forum. All rights reserved.