def tfidf():
if not TFIDF:
return
doc1 = u'Andrew likes Diet Pepsi.'
doc2 = u'Andrew knows the muffin man.'
doc3 = u'Andrew lives near the muffin man on Shirley Lane.'
corpus = map(sip.noun_phrases, [doc1, doc2, doc3])
dictionary = corpora.Dictionary(corpus)
bows = [dictionary.doc2bow(tokens) for tokens in corpus]
return models.TfidfModel(bows, id2word=dictionary)
评论列表
文章目录