Why do I get "invalid syntax" in the line with the % start S?
nltk.data.show_cfg('grammars/book_grammars/feat0.fcfg')
% start S
S -> NP[NUM=?n] VP[NUM=?n]
# NP expansion productions
NP[NUM=?n] -> PropN[NUM=?n]
NP[NUM=?n] -> Det[NUM=?n] N[NUM=?n]
NP[NUM=pl] -> N[NUM=pl]
As @cody pointed out, this is the code part:
That outputs these:
When attempting to type the following:
You'll see a
SyntaxError
because it's not Python, it's the NLTK specific sublanguage to write the.cfg
/.fcfg
grammar.