You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from nltk.grammar import CFG
grammar = CFG.fromstring("""
# Grammatical productions.
S -> NP VP
NP -> Det N PP | Det N
VP -> V NP PP | V NP | V
PP -> P NP
# Lexical productions.
NP -> 'I'
Det -> 'the' | 'a'
N -> 'man' | 'park' | 'dog' | 'telescope'
V -> 'ate' | 'saw'
P
will pyStatParser output a CFG string for the grammar?
The text was updated successfully, but these errors were encountered:
parser = Parser()
text="How can the net amount of entropy of the universe be massively decreased?"
sent=text.split()
tree = parser.parse(text)
print tree
grammar = parser.pcfg
RecursiveDescentApp(grammar, sent).mainloop()
that fails with
Traceback (most recent call last):
File "wordstree.py", line 906, in <module>
app()
File "wordstree.py", line 903, in app
RecursiveDescentApp(grammar, sent).mainloop()
File "wordstree.py", line 120, in __init__
self._init_grammar(self._top)
File "wordstree.py", line 166, in _init_grammar
self._productions = list(self._parser.grammar().productions())
Supposed to have
will
pyStatParser
output a CFG string for the grammar?The text was updated successfully, but these errors were encountered: