What is a CFG for these sentences?
Consider this sentence:
If we would see the Context Free Grammar for this simple sentence we would get:
S -> NP VP
Where NP is ProperNoun and VP is a verb
But how would you construct a CFG for these sentences?
when does Lisa drink the milk on the table
Homer never drinks milk in the kitchen before midnight
For the second sentence I think I have a clue, CFG for it should be this:
(S (NP (Nom (PropN Homer) (Adj never))) (VP (V drinks) (Nom (N milk) (PP (P in) (Nom (Det the) (N kitchen) (Nom (Adj before) (N midnight)))))))
So my question is, what are the CFGs for those two sentences and am I getting a CFG for the second sentence correct? Thank you
My CFG looks like this:
grammar2 = nltk.CFG.fromstring(''' S -> NP VP | Wh NP VP NP -> Nom | PropN | PropN C PropN Nom -> PropN Adj VP -> V | V N | V Nom | V S | V N S Nom -> Adj N | N PP PP -> P Nom Nom -> Det N Nom Nom -> Adj N PropN -> "Bart" | "Homer" | "Lisa" Adj -> "always" | "blue" | "never" | "before" | "healthy" | "green" V -> "wears" | "drinks" | "laughs" | "laughed" | "drink" | "serves" | "thinks" | "wear" N -> "shoes" | "milk" | "midnight" | "kitchen" | "salad" Det -> "the"| "a" P -> "in" C -> "and" Wh -> "when" ''')
I am using NLTK 3.0 for this task (just in case).