如何获得给定偏移 ID 的 WordNet 同义词集? [英] How to get the WordNet synset given an offset ID?

查看:36
本文介绍了如何获得给定偏移 ID 的 WordNet 同义词集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WordNet 同义词偏移(例如 id="n#05576222").鉴于此偏移量,我如何使用 Python 获取同义词集?

I have a WordNet synset offset (for example id="n#05576222"). Given this offset, how can I get the synset using Python?

推荐答案

从 NLTK 3.2.3 开始,有一个公共方法可以做到这一点:

As of NLTK 3.2.3, there's a public method for doing this:

wordnet.synset_from_pos_and_offset(pos, offset)

在早期版本中,您可以使用:

In earlier versions you can use:

wordnet._synset_from_pos_and_offset(pos, offset)

这将返回一个基于 POS 和offest ID 的同义词集.我认为此方法仅在 NLTK 3.0 中可用,但我不确定.

This returns a synset based on it's POS and offest ID. I think this method is only available in NLTK 3.0 but I'm not sure.

示例:

from nltk.corpus import wordnet as wn
wn.synset_from_pos_and_offset('n',4543158)
>> Synset('wagon.n.01')

这篇关于如何获得给定偏移 ID 的 WordNet 同义词集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆