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
.
This exercise is part of the course
Introduction to Natural Language Processing in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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(____)