【发布时间】:2015-09-06 04:05:23
【问题描述】:
我有这个 sn-p 用于获取同义词(我从其中一个帖子中得到它)。我想在列表中获取同义词,而不是如下所示的打印方式
from nltk.corpus import wordnet as wn
import nltk
from nltk.corpus.reader.plaintext import PlaintextCorpusReader
def me():
T = []
for i,j in enumerate(wn.synsets('small')):
#print "Synonyms:", ", ".join(j.lemma_names())
for item in [", ".join(j.lemma_names())]:
print T.append(item)
如果我使用:
print item,
我得到了这个答案:
small
small
small, little
minor, modest, small, small-scale, pocket-size, pocket-sized
little, small
small
humble, low, lowly, modest, small
little, minuscule, small
little, small
small
modest, small
belittled, diminished, small
small
如果我使用
print T.append(item),
我明白了:
None
None
None
None
None
None
None
None
None
None
None
None
None
我想要的是这个:
[ small, little, minor, modest, small-scale, pocket-size, pocket-sized, humble, low, lowly, minuscule, belittled, diminished]
【问题讨论】:
标签: python-2.7 nlp nltk wordnet