top of page

Context-free Grammars

It is a kind of method that divided a sentence into some elements systematically.  For example, the sentence “I like cats” can be divided into “object+verb+subject”.  Which means, I can put any noun into the object or the subject part and put any verb into the verb part.  For example, Buddha plays Jesus.  Although the context is weird or even not logical, the sentence is grammatically correct and this is the core idea of the context-free grammar.

 

According to this concept, we can develop the sentence to a more complex sentence.  For example, “You cannot cut your nail at night”, we can divide this sentence into a more mathematical way and set the rules to make the sentence.

 

First draft for the idea flow: 

sentence = x

x = a + cannot + b.

a = object

b = verb + subject

b = verb + subject + time 

object = You / Woman / Children / Man 

verb = cut / play / touch / eat / use / see 

subject = body part / wall

time = at night / at midnight /  before sunrise / after sunset

body part = nail / hair / eyes / saliva

 

Follow the rules, sub items until it become a terminal (which means that there are no other words can instead the word under the rules).  

 

x

a + cannot + b

object +  cannot + b

object+cannot+verb+subject+time

Woman+cannot+verb+subject+time

Woman+cannot+eats+subject+time

Woman+cannot+eats+body part+time

Woman+cannot+eats+eyes+time

Woman+cannot+eats+eyes+after sunset

 

Then after the combine, the result can be : Woman cannot eat eyes after sunset.

Reference:

Point, T. (2017, August 15). Context-Free Grammar Introduction. Retrieved December 05, 2017, from https://www.tutorialspoint.com/automata_theory/context_free_grammar_introduction.htm

RiGrammar. (n.d.). Retrieved December 05, 2017, from https://rednoise.org/rita/reference/RiGrammar.php

Tutorial > Generating with RiGrammar. (n.d.). Retrieved December 05, 2017, from https://rednoise.org/rita/tutorial/grammars.php

bottom of page