我如何转换[Synset('dog.n.01'),Synset('frump.n.01'),Synset('dog.n.03'),Synset('cad

时间:2014-10-31 00:16:53

标签: python algorithm python-3.x

我如何转换

[Synset('dog.n.01'), Synset('frump.n.01'), Synset('dog.n.03'), Synset('cad.n.01'), Synset('frank.n.02'), Synset('pawl.n.01'), Synset('andiron.n.01'), Synset('chase.v.01')] 

'dog.n.01', 'frump.n.01', 'dog.n.03', 'cad.n.01', 'frank.n.02', 'pawl.n.01', 'andriron.n.01', 'chase.v.01'

在python中

请注意原始文本是来自NLTK库的wordnet.synsets('dog')的输出

提前致谢

1 个答案:

答案 0 :(得分:2)

我认为这些数据来自NLTK?

from nltk.corpus import wordnet as wn
syns = wn.synsets('dog')

如果是,请尝试:

names = [ s.name() for s in syns ] 

获取名称列表。

(将来,请提供有关数据来源的更多背景信息。)