中易网

python怎么使用wordnet

答案:3  悬赏:60  
解决时间 2021-03-08 17:40
python怎么使用wordnet
最佳答案
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')]
全部回答
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") 在第一个sense中,print和publish都是lemma。Sense 1括号内的数字39表示publish以sense 1在某外部语料中出现的次数。显然,publish大多数时候以sense 1出现,很少以sense 3出现。 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')] 得到synset的词性: >>>related.pos 's' 得到一个sense的所有lemma: >>>wordnet.synsets('publish')[0].lemmas [Lemma('print.v.01.print'), Lemma('print.v.01.publish')] 得到Lemma出现的次数: >>> wordnet.synsets('publish')[0].lemmas[1].count() 39 在wordnet中,名词和动词被组织成了完整的层次式分类体系,因此可以通过计算两个sense在分类树中的距离,这个距离反应了它们的语义相似度: >>> x =wordnet.synsets('recommended')[-1] >>> y =wordnet.synsets('suggested')[-1] >>> x.shortest_path_distance(y) 0 形容词和副词的相似度计算方法: 形容词和副词没有被组织成分类体系,所以不能用path_distance。 >>> a =wordnet.synsets('beautiful')[0] >>> b =wordnet.synsets('good')[0] >>>a.shortest_path_distance(b) -1 形容词和副词最有用的关系是similar to。 >>> a =wordnet.synsets('glorious')[0] >>>a.similar_tos() [Synset('incandescent.s.02'), Synset('divine.s.06'), ……]
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") 在第一个sense中,print和publish都是lemma。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
求生之路2打不开了,那位大神救救我!!!问
新空间装饰材料这个地址在什么地方,我要处理
蒙迪欧致胜左后车门老显示未关门,但其实已经
问下啊 做梦梦到鬼(在梦里自己认为那是鬼)
我姐老说我儿子小短腿 什么意思
万达电影在网上买了票能不能退?
聚点广告设计工作室在什么地方啊,我要过去处
wow什么意思中文
马牌轮胎225/45/zr17 91w fr mc5 花纹是这个
元朝的开国皇帝姓什么?
一个人的价值,应该看他贡献什么,而不应当看
到外资企业上班英语要求什么样的水平
办小学生托管注意什么 遇到不爱写作业的学生
四季沐歌太阳能(月山专卖店)怎么去啊,有知道
储蓄卡是不是一定要回到所开地注销啊?
推荐资讯
一个月宝宝贫血太严重会有什么影响
真挚的友情的作文600字
看甄子丹的叶问从头到尾都没有高踢腿动作,他
龙源期刊如何下载PDF格式?文本模式看不到图
幻影wifi破解过程中是不是不能连wifi啊?
杭州同城快递大概多久收到?
锦丽华庭(东北门)我想知道这个在什么地方
一开单三孔可以插同时电脑和电饭煲吗
rep ciminga com体检结果
valentine做名字的话,是属于英文名还是其它
幽门螺旋杆菌病是如何得的
苍南县灵溪镇蒙恩冷冻食品商行怎么去啊,有知
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?