【发布时间】:2017-11-18 08:35:33
【问题描述】:
我正在计算 tf-idf 如下。
texts=['human interface computer',
'survey user computer system response time',
'eps user interface system',
'system human system eps',
'user response time']
dictionary = corpora.Dictionary(texts)
corpus = [dictionary.doc2bow(text) for text in texts]
tfidf = models.TfidfModel(corpus)
corpus_tfidf = tfidf[corpus]
analyzedDocument = namedtuple('AnalyzedDocument', 'word tfidf_score')
d=[]
for doc in corpus_tfidf:
for id, value in doc:
word = dictionary.get(id)
score = value
d.append(analyzedDocument(word, score))
但是,现在我想使用具有最高 idf 值的词来识别我的语料库中最重要的 3 个词。请告诉我该怎么做?
【问题讨论】: