这可能是愚蠢的,但我似乎无法通过wn.synsets('wheeled vehicle')(通过wn创建的from nltk.corpus import wordnet as wn)找到“轮式车辆”之类的单词---返回空数组,但是我可以在princeton wordnetweb online search上找到它

可能有人知道我在想什么吗?还是推荐更好的库?

谢谢!

最佳答案

对于多字词引理,请使用下划线而不是空格。

>>> from nltk.corpus import wordnet as wn

# Retrieve the synsets that're associated with lemma "wheeled vehicle"
>>> wn.synsets('wheeled_vehicle')
[Synset('wheeled_vehicle.n.01')]

>>> wn.synsets('wheeled_vehicle')[0].definition()
u'a vehicle that moves on wheels and usually has a container for transporting things or people'


要直接访问同义集,您需要知道同义集的POS和引理索引:

>>> wn.synset('wheeled_vehicle.n.01')
Synset('wheeled_vehicle.n.01')

关于python - 在nltk wordnet中找不到的短语,但可以通过princeton wordnetweb在线搜索找到,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45806759/

10-09 03:50