刘华
实验室:JS测试器
分类专栏
hadoop2篇
mysql1篇
nginx8篇
java5篇
架构设计3篇
信息安全6篇
前端开发2篇
数据同步6篇
AI7篇
其他9篇

python怎么使用wordnet(转)

liuhua-2019/6/25 14:29:26

Wordnet是一个词典。每个词语(word)可能有多个不同的语义,对应不同的sense。而每个不同的语义(sense)又可能对应多个词,如topic和subject在某些情况下是同义的,一个sense中的多个消除了多义性的词语叫做lemma。例如,“publish”是一个word,它可能有多个sense:

1. (39) print,publish -- (put into print; "The newspaper published the news of the royalcouple's divorce"; "These news should not be printed")
2. (14) publish,bring out, put out, issue, release -- (prepare and issue for publicdistribution or sale; "publish a magazine or newspaper")
3. (4) publish,write -- (have (one's written work) issued for publication; "How manybooks did Georges Simenon write?"; "She published 25 books during herlong career")

WordNet的具体用法
NLTK是python的一个自然语言处理工具,其中提供了访问wordnet各种功能的函数。下面简单列举一些常用功能:

得到wordnet本身:
from nltk.corpusimport wordnet

获得一个词的所有sense,包括词语的各种变形的sense:
wordnet.synsets('published')
[Synset('print.v.01'),
Synset('publish.v.02'),
Synset('publish.v.03'),
Synset('published.a.01'),
Synset('promulgated.s.01')]


小钉 京ICP备16032583号-1