WordNet
来源:互联网 发布:淘宝分销自动分账 编辑:程序博客网 时间:2024/05/21 17:42
from http://blog.csdn.net/ictextr9/archive/2009/03/20/4008703.aspx
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
- Wordnet
- WordNet
- wordnet
- WordNet
- WordNet
- wordnet
- Visual Wordnet
- wordnet manual
- WordNet介绍
- WordNet使用方法
- WordNET 安装
- WordNet 简介
- WordNet发展概况
- WordNet介绍和使用
- 使用JWNL读取WordNet
- WordNet介绍和使用
- NLTK之WordNet 接口
- 有关引用的汇编层面探索
- centos6.0桌面配置
- hbm文件如何打包在jar中不出现资源文件找不到的问题
- Wifi开发- WlanOpenHandle -介绍
- 关于linux bash shell中sort命令指定分隔符的用法
- WordNet
- 两个周的折腾(一)——在线文本编辑器
- Android游戏开发之数据库SQLite 详细介绍(十七)
- 文字用指定的编码方式编码
- 回文数字2
- 指针与数组
- C99标准的新特性(相对于Ansi C)
- 在非托管环境下使用托管环境下的程序集(转)
- 内存分配