我有一组单词(n-gram),我需要计算tf-idf值。这些话是;
myvocabulary = ['tim tam', 'jam', 'fresh milk', 'chocolates', 'biscuit pudding']
我的语料库如下所示。
corpus = {1: "making chocolates biscuit pudding easy first get your favourite biscuit chocolates", 2: "tim tam drink new recipe that yummy and tasty more thicker than typical milkshake that uses normal chocolates", 3: "making chocolates drink different way using fresh milk egg"}
我目前使用sklearn在myvocabulary
中获取我的n-gram的tf-idf值,如下所示。
tfidf = TfidfVectorizer(vocabulary = myvocabulary, ngram_range = (1,3))
tfs = tfidf.fit_transform(corpus.values())
但是,我有兴趣在Gensim做同样的事情。 Forall我在Gensim遇到的例子;
myvocabulary
中的单词)因此,请帮助我了解如何在Gensim中完成上述两件事。