Python自然语言处理笔记(三)wordnet层次结构

  • 上位词集hypernyms()
#查看上位词
>>> computer.hypernyms()
[Synset('machine.n.01')]
#computer的词汇路径,所有的上位词
>>> paths=computer.hypernym_paths()
>>> len(paths)
1
>>> synset.name() for synset in paths[0]
SyntaxError: invalid syntax
>>> print(paths)
[[Synset('entity.n.01'), Synset('physical_entity.n.01'), Synset('object.n.01'), Synset('whole.n.02'), Synset('artifact.n.01'), Synset('instrumentality.n.03'), Synset('device.n.01'), Synset('machine.n.01'), Synset('computer.n.01')]]
  • 最低共同上位词集lowesr_common_hypernyms()
right.lowest_common_hypernyms(minke) #查找right与minke的共同上位词
  • 根上位词集root_hypernyms()
motorcar.root_hypernyms()
[Synset('entity.n.01')]
  • 下位词集hyponyms()
#查看motorcar的下位词
motorcar = wn.synset('car.n.01')
types_of_motorcar = motorcar.hyponyms()
types_of_motorcar[26]
sorted([lemma.name() for synset in types_of_motorcar for lemma in synset.lemmas()])

参考wordnet 词汇层次结构及词汇关系总结
Python自然语言处理第二章-2.5 WordNet(II)——wordnet的层次结构

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值