S
Sohail
Hi,
When I define my own production rules for the grammar the code below
runs fine. Can anyone tell me how to use the built in grammars of nltk
(if there are any)?
.... S -> NP VP
.... PP -> P NP
.... NP -> Det N | Det N PP | 'I'
.... VP -> V NP | VP PP
.... Det -> 'an' | 'my'
.... N -> 'elephant' | 'pajamas'
.... V -> 'shot'
.... P -> 'in'
.... """)
thanks
When I define my own production rules for the grammar the code below
runs fine. Can anyone tell me how to use the built in grammars of nltk
(if there are any)?
.... S -> NP VP
.... PP -> P NP
.... NP -> Det N | Det N PP | 'I'
.... VP -> V NP | VP PP
.... Det -> 'an' | 'my'
.... N -> 'elephant' | 'pajamas'
.... V -> 'shot'
.... P -> 'in'
.... """)
.... print treesent = ['I', 'shot', 'an', 'elephant', 'in', 'my', 'pajamas']
parser = nltk.ChartParser(groucho_grammar)
trees = parser.nbest_parse(sent)
for tree in trees:
thanks