使用 wordnet 获取单词的引理

发布于 2024-11-25 16:29:20 字数 392 浏览 2 评论 0原文

如何使用 Wordnet 获取给定单词的引理。我似乎无法在 wordnet 文档中找到我想要的内容。 http://wordnet.princeton.edu/wordnet/man/wn.1WN.html

例如,对于“books”这个词,我想得到“book”,ashes =>灰烬,预订=>书,苹果=>苹果....等

我想在命令行中使用 wordnet 来实现这一点,但我找不到检索这种情况的确切选项。

php 解决方案也会有很大帮助,因为我最初打算使用 wordnet php API,但他们网站上的当前 API 似乎无法正常工作。

How can I get the lemma for a given word using Wordnet. I couldn't seem to find in the wordnet documentation what i want. http://wordnet.princeton.edu/wordnet/man/wn.1WN.html

For example for the word "books" i want to get "book" , ashes => ash , booking => book, apples => apple .... etc.

i want to achieve this using wordnet in command line and I cant find exact options to retrieve such case.

A php solution would also be of great help because I originally intend to use the wordnet php API but it seems the current one in their website isn't working.

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

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

发布评论

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

评论(4

乱世争霸 2024-12-02 16:29:20

Morphy 是 WordNet 原生的形态处理器。 WordNet 接口调用 Morphy 来对单词进行词形还原,作为查找过程的一部分(例如,您查询“enlightened”,它会返回“enlightened”的结果,并通过 Morphy 返回“enlighten”的结果)。

这些界面不包含允许用户直接访问 Morphy 的功能,因此只有当您使用 WordNet API 之一编写自己的程序时才能在命令行中使用它。您可以在 WordNet 站点上找到 Morphy 的文档

据我所知,PHP 接口仍然可用,尽管您可能需要使用 WordNet 2 .x。

Morphy is a morphological processor native to WordNet. The WordNet interfaces invoke Morphy to lemmatize a word as part of the lookup process (e.g. you query "enlightened", it returns the results for both "enlightened" and, via Morphy, "enlighten").

The interfaces don't include a feature that allows a user to directly access Morphy, so using it in command line is only possible if you write your own program using one of the WordNet APIs. You can find documentation for Morphy at the WordNet site.

As near as I can tell, the PHP interface is still available, although you may need to use WordNet 2.x.

空城之時有危險 2024-12-02 16:29:20

如果您可以使用其他工具,请尝试 TreeTagger

If you can use another tool try TreeTagger.

落叶缤纷 2024-12-02 16:29:20

我不确定 WordNet 本身是否实现了它。 NLTK 有 Morphy,它完全可以满足您的需求,但它是用 Python 实现的。您可以编写一个小型 Python 程序来从命令行获取输入并返回引理。

在以下链接中搜索“Morphy”:
http://nltk.googlecode .com/svn/trunk/doc/api/nltk.corpus.reader.wordnet.WordNetCorpusReader-class.html

nltk.WordNetLemmatizer() 也可以完成这项工作。在以下链接中搜索“词形还原”:
http://nltk.googlecode.com/svn/trunk/doc/book /ch03.html

NLTK 网站:http://www.nltk.org/

I am not sure that WordNet implements it natively. NLTK has Morphy, which precisely does what you want, but it is implemented in Python though. You can write a small Python program to take input from the command line and return the lemma.

Search for 'Morphy' in the following link:
http://nltk.googlecode.com/svn/trunk/doc/api/nltk.corpus.reader.wordnet.WordNetCorpusReader-class.html

nltk.WordNetLemmatizer() also does the job. Search for 'Lemmatization' in the following link:
http://nltk.googlecode.com/svn/trunk/doc/book/ch03.html

NLTK website : http://www.nltk.org/

昨迟人 2024-12-02 16:29:20

nltk 库中的 WordNetLemmatizer 将满足您的需要。这是 python3 代码:

#!Python3 -- this is lemmatize_s.py
import nltk
from nltk.stem import WordNetLemmatizer
from nltk.tokenize import word_tokenize
print ("This program will lemmatize your input until you ask for it to 'end'.")
while True:
    sentence = input("Type one or more words (or 'end') and press enter:")
    if (sentence == "end"):
        break
    tokens = word_tokenize(sentence)
    lemmatizer = WordNetLemmatizer()
    Output=[lemmatizer.lemmatize(word) for word in tokens]
    print (Output);

从命令行运行:

eyeMac2016:james$ python3 lemmatize_s.py
This program will lemmatize your input until you ask for it to 'end'.
Type one or more words  (or 'end') and press enter:books ashes
['book', 'ash']
Type one or more words  (or 'end') and press enter:end
eyeMac2016:james$ 

The WordNetLemmatizer in the nltk library will do what you need. here is python3 code:

#!Python3 -- this is lemmatize_s.py
import nltk
from nltk.stem import WordNetLemmatizer
from nltk.tokenize import word_tokenize
print ("This program will lemmatize your input until you ask for it to 'end'.")
while True:
    sentence = input("Type one or more words (or 'end') and press enter:")
    if (sentence == "end"):
        break
    tokens = word_tokenize(sentence)
    lemmatizer = WordNetLemmatizer()
    Output=[lemmatizer.lemmatize(word) for word in tokens]
    print (Output);

Running this from the command line:

eyeMac2016:james$ python3 lemmatize_s.py
This program will lemmatize your input until you ask for it to 'end'.
Type one or more words  (or 'end') and press enter:books ashes
['book', 'ash']
Type one or more words  (or 'end') and press enter:end
eyeMac2016:james$ 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文