运行以下命令需要哪些软件包?
import nltk
from nltk.corpus import wordnet
v = 'go'
present = present_tense(v)
I got an error saying-
NameError:名称'present_tense'未定义
答案 0 :(得分:3)
您可以尝试:import en
而不是:import nltk
您可以尝试:en.verb.present(v)
而不是:present_tense(v)
en包来自NodeBox English Linguistics library
演示网站:http://wnbot.com/wordnet/stackoverflow.py
草稿源代码清单:
#!/usr/bin/python
import en
import sys
went = 'went'
going = 'going'
gone = 'gone'
goes = 'goes'
print "Content-Type: text/html"
print
print "<html><head><title>Stack Overflow answer</title></head><body>"
print ' The present tense of <b>',going, '</b> is <i>',en.verb.present(going),'</i><br>'
print ' The present tense of <b>',goes, '</b> is <i>',en.verb.present(goes),'</i><br>'
print ' The present tense of <b>',gone, '</b> is <i>',en.verb.present(gone),'</i><br>'
print ' The present tense of <b>',went, '</b> is <i>',en.verb.present(went),'</i><br>'
print "</body></html>"
此源代码清单仅供教育和讨论之用。