‘看看你是否能打印出引理狗的所有同义词集定义。’
因此,在本练习中,我被告知要运行代码并下载nltk,然后查找引理“狗”的所有同义词定义。
下载运行,并显示'true‘,因此下载了nltk。
但是,当我想要从nltk_data.corpora ( nltk文件夹语料库)导入wordnet时,我可以导入它,但wordnet字典中的属性'synset‘输出为:’AttributeError‘。
我可以用什么方式为引理'dog‘带来同义词集的输出?
## help found on https://www.nltk.org/howto/wordnet.html
import nltk_data
from nltk_data.corpora import wordnet as wn
dog = wn.synset('dog.n.01')发布于 2021-11-23 04:45:53
Wn.synsets(‘狗’)
[Synset('dog.n.01'), Synset('frump.n.01'), Synset('dog.n.03'), Synset('cad.n.01'), Synset('frank.n.02'), Synset('pawl.n.01'), Synset('andiron.n.01'), Synset('chase.v.01')]Wn.synsets中syn的syn.definition() (‘wn.synsets’)
['a member of the genus Canis (probably descended from the common wolf) that has been domesticated by man since prehistoric times; occurs in many breeds', 'a dull unattractive unpleasant girl or woman', 'informal term for a man', 'someone who is morally reprehensible', 'a smooth-textured sausage of minced beef or pork usually smoked; often served on a bread roll', 'a hinged catch that fits into a notch of a ratchet to move a wheel forward or prevent it from moving backward', 'metal supports for logs in a fireplace', 'go after with the intent to catch']https://stackoverflow.com/questions/69375627
复制相似问题