Skip to content

Instantly share code, notes, and snippets.

@joshua-taylor
Created November 24, 2019 13:05
Show Gist options
  • Save joshua-taylor/11b59363bf13bbb6243338c71146b68a to your computer and use it in GitHub Desktop.
Save joshua-taylor/11b59363bf13bbb6243338c71146b68a to your computer and use it in GitHub Desktop.
import IPython
tkn = tfidf.build_tokenizer()
sent = df.questionText.values[236178].lower()
sent = tkn(sent)
html=''
for wrd in sent:
try:
weight = (tfidf.idf_[tfidf.vocabulary_[wrd]])*10
print(weight/10)
except:
weight = 1
print('{} not found'.format(wrd))
html+='<span style="font-size:{}px">{} </span>'.format(weight,wrd)
IPython.display.HTML(html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment