I'm trying to run this example provided from NLTK book here:
>>> from nltk import load_parser
>>> cp = load_parser('grammars/book_grammars/sql0.fcfg')
>>> query = 'What cities are located in China'
>>> trees = list(cp.parse(query.split()))
>>> answer = trees[0].label()['SEM']
>>> answer = [s for s in answer if s]
>>> q = ' '.join(answer)
>>> print(q)
SELECT City FROM city_table WHERE Country="china"
but when I type the first line it gives me this error:
NameError: name 'load_parser' is not defined
I tried looking for similar questions but none have the same issue. How can I fix it?
I removed all nltk_data files and downloaded them again and it worked.