[英]Calculate tf-idf in Gensim for my vocabulary
I have a set of words (n-grams) where I need to calculate tf-idf values. 我有一组需要计算tf-idf值的单词(n-gram)。 These words are;
这些话是;
myvocabulary = ['tim tam', 'jam', 'fresh milk', 'chocolates', 'biscuit pudding']
My corpus looks as follows. 我的语料库如下。
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"}
I am currently getting tf-idf values for my n-grams in myvocabulary
using sklearn as follows. 我目前得到的TF-IDF值,我正克
myvocabulary
使用sklearn如下。
tfidf = TfidfVectorizer(vocabulary = myvocabulary, ngram_range = (1,3))
tfs = tfidf.fit_transform(corpus.values())
However, I am interested in doing the same in Gensim. 但是,我有兴趣在Gensim中进行相同的操作。 Forall the examples I came across in Gensim;
我在Gensim中遇到的所有例子都是如此。
myvocabulary
) myvocabulary
的单词计算) Hence, please help me to find out how to do the above two things in Gensim. 因此,请帮助我找出如何在Gensim中完成以上两件事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.