2017-10-09 6 views
0

나는 tf-idf 값을 계산해야하는 단어 집합 (n-gram)이 있습니다. 이 단어들은;내 어휘의 Gensim에서 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-그램 TF-IDF 값을 얻고있다.

tfidf = TfidfVectorizer(vocabulary = myvocabulary, ngram_range = (1,3)) 
tfs = tfidf.fit_transform(corpus.values()) 

그러나 Gensim에서 동일한 작업을하는 데 관심이 있습니다. 내가 Gensim에서 만난 예를 들어라.

  1. 이 (bigrams 위해 iwant뿐만 아니라 괘) 만 unigrams를 사용

따라서 (난 단지 myvocabulary의 단어를 계산할) 모든 단어에 대해 계산

  • , 저를 도와주세요 Gensim에서 위의 두 가지를 수행하는 방법을 찾으십시오. 방법

  • 답변

    0

    gensim에서 사전을 위해, 당신은 불행하게도 examples

    보면, gensim.corpora.Dictionary 클래스를 사용해야합니다, 우리는 Phrases 클래스와 단어를 bigrams, 일반적으로 어떤 지원 ngrams이 없습니다

    +0

    당신은 말해 줄 수 bigrams를 사용하여 tf-idf를 계산 하시겠습니까? bigrams는 나를 위해 충분하다 :) –

    +0

    1. 텍스트 처리 2. 문구 맞추기 + 텍스트에 적용 (bigrams로 새 텍스트 제공) 3. TfidfModel –

    +0

    을 사용하여 tfidf를 계산합니다. 제가 가진 질문입니다. 선택된 bigram을 입력하는 방법 tf-idf를 tfidfmodel로 계산하고 싶습니다 : D –