IniziaInizia gratis

Tf-idf with Wikipedia

Now it's your turn to determine new significant terms for your corpus by applying gensim's tf-idf. You will again have access to the same corpus and dictionary objects you created in the previous exercises - dictionary, corpus, and doc. Will tf-idf make for more interesting results on the document level?

TfidfModel has been imported for you from gensim.models.tfidfmodel.

Questo esercizio fa parte del corso

Introduction to Natural Language Processing in Python

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Create a new TfidfModel using the corpus: tfidf
tfidf = ____

# Calculate the tfidf weights of doc: tfidf_weights
tfidf_weights = ____

# Print the first five weights
print(____)
Modifica ed esegui il codice