1
我有這個片段來獲取同義詞(我從其中一篇文章中獲得)。我想要得到的同義詞列表中,而不是因爲它打印如下圖所示如何獲得NLP的同義詞
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
, 我得到這樣的回答:如果我使用 print T.append(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
, 我得到這個:
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]