3

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

例如,对于“books”这个词,我想得到“book”,ashes => ash,booking => book,apples => apple .... 等。

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

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

4

4 回答 4

2

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

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

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

于 2012-07-11T18:14:09.927 回答
2

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

于 2012-07-11T20:44:23.740 回答
1

我不确定 WordNet 是否本机实现它。NLTK 有 Morphy,它正是你想要的,但它是用 Python 实现的。您可以编写一个小型 Python 程序来从命令行获取输入并返回引理。

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

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

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

于 2011-07-24T19:29:32.570 回答
0

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$ 
于 2016-10-05T05:20:07.753 回答