Skip to content

Instantly share code, notes, and snippets.

@andrea-dagostino
Created October 3, 2022 08:59
Show Gist options
  • Select an option

  • Save andrea-dagostino/e1f23b8d10340feb7b2c0f61455f3fc7 to your computer and use it in GitHub Desktop.

Select an option

Save andrea-dagostino/e1f23b8d10340feb7b2c0f61455f3fc7 to your computer and use it in GitHub Desktop.
text_sim_tfidf
def compute_similarity(a, b):
tfidf = vectorizer.fit_transform([a, b])
return ((tfidf * tfidf.T).toarray())[0,1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment