我是NLTK Python的新手,我正在寻找一些可以进行词义消歧的示例应用程序.我在搜索结果中有很多算法,但没有示例应用程序.我只想传递一个句子,并希望通过引用wordnet库来了解每个单词的含义.谢谢
我在PERL中找到了一个类似的模块.http://marimba.d.umn.edu/allwords/allwords.html NLTK Python中是否有这样的模块?
alv*_*vas 12
最近,部分pywsd代码已被移植到NLTK' wsd.py模块中的最新版本中,请尝试:
>>> from nltk.wsd import lesk
>>> sent = 'I went to the bank to deposit my money'
>>> ambiguous = 'bank'
>>> lesk(sent, ambiguous)
Synset('bank.v.04')
>>> lesk(sent, ambiguous).definition()
u'act as the banker in a game or in gambling'
Run Code Online (Sandbox Code Playgroud)
为了获得更好的WSD性能,请使用pywsd库而不是NLTK模块.在一般情况下,simple_lesk()从pywsd确实优于lesk从NLTK.NLTK当我有空时,我会尝试尽可能多地更新模块.
在回应Chris Spencer的评论时,请注意Lesk算法的局限性.我只是给出了算法的准确实现.它不是一个银弹,http://en.wikipedia.org/wiki/Lesk_algorithm
另请注意,尽管如此:
lesk("My cat likes to eat mice.", "cat", "n")
Run Code Online (Sandbox Code Playgroud)
不给你正确的答案,你可以使用pywsd实施max_similarity():
>>> from pywsd.similarity import max_similiarity
>>> max_similarity('my cat likes to eat mice', 'cat', 'wup', pos='n').definition
'feline mammal usually having thick soft fur and no ability to roar: domestic cats; wildcats'
>>> max_similarity('my cat likes to eat mice', 'cat', 'lin', pos='n').definition
'feline mammal usually having thick soft fur and no ability to roar: domestic cats; wildcats'
Run Code Online (Sandbox Code Playgroud)
@Chris,如果你想要一个python setup.py,只是做一个礼貌的请求,我会写它...
是的,事实上,有一本书是NLTK团队编写的,其中有多章分类,并明确涵盖了如何使用WordNet.您还可以从Safari购买该书的实际版本.
仅供参考:NLTK由自然语言程序设计学者编写,用于他们的入门编程课程.
| 归档时间: |
|
| 查看次数: |
13858 次 |
| 最近记录: |