如何在Python中使用nltk和WordNet获取单词的过去时?

发布于 2024-10-28 22:10:44 字数 241 浏览 6 评论 0原文

运行以下命令需要哪些软件包?

代码

import nltk
from nltk.corpus import wordnet
v = 'go'
present = present_tense(v)
I got an error saying-

错误信息

名称错误:名称“present_tense”未定义

What are the packages required to run the below commands?

Code

import nltk
from nltk.corpus import wordnet
v = 'go'
present = present_tense(v)
I got an error saying-

Error message

NameError: name 'present_tense' is not defined

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吻泪 2024-11-04 22:10:44

您可以尝试:import en
而不是:import nltk

您可以尝试:en.verb.present(v)
而不是: present_tense(v)

en 包来自 NodeBox English Linguistics库

演示站点: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>"

此源代码列表是仅用于教育和讨论目的的草稿。

You may try: import en
instead of: import nltk

You may try: en.verb.present(v)
instead of: present_tense(v)

The en package is from the NodeBox English Linguistics library

Demo site: http://wnbot.com/wordnet/stackoverflow.py

Draft source code listing:

#!/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>"

This source code listing is a draft for educational and discussion purposes only.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文