Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn TF-ISF Score | Extracting Text Meaning using TF-IDF
Extracting Text Meaning using TF-IDF

book
TF-ISF Score

The TF-ISF score for a word is derived by multiplying its TF score by its ISF score . This composite score encapsulates both the word's relevance within individual sentences and its distinctiveness within the broader textual landscape.

Task

Swipe to start coding

  1. Enumerate through tokenized sentences along with their indices.
  2. Сalculate TF-ISF scores for each word.
  3. Append calculated TF-ISF scores to the tf_isf_scores list.

Solution

# Initialize an empty list to store the TF-ISF scores for all sentences
tf_isf_scores = []

# Enumerate through the list of tokenized sentences along with their index
for index, sentence in enumerate(tokenized_sentences):
# Initialize an empty dictionary for storing the TF-ISF scores of the current sentence
sentence_tf_isf = {}
# Iterate through each word in the current sentence
for word in sentence:
# Check if the current word has both TF and ISF scores calculated
if word in tf_scores[index] and word in isf_scores:
# Calculate the TF-ISF score for the current word
sentence_tf_isf[word] = tf_scores[index][word] * isf_scores[word]
# Append the dictionary of TF-ISF scores
tf_isf_scores.append(sentence_tf_isf)
# Display the TF-ISF scores for the first two sentences
tf_isf_scores[:2]

Mark tasks as Completed
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 10
AVAILABLE TO ULTIMATE ONLY
some-alt