我正在尝试在这里运行 NLTK 书中提供的这个示例:
>>> 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"
但是当我输入第一行时,它给了我这个错误:
NameError: name 'load_parser' is not defined
我尝试寻找类似的问题,但没有一个有相同的问题。我该如何解决?