Skip to content

Instantly share code, notes, and snippets.

@bee-san
Last active August 27, 2018 13:16
Show Gist options
  • Select an option

  • Save bee-san/9630279836fa9994fd971f8f417e641f to your computer and use it in GitHub Desktop.

Select an option

Save bee-san/9630279836fa9994fd971f8f417e641f to your computer and use it in GitHub Desktop.
function TFIDF(documents){
// calculates TF*IDF
const TFVals = termFrequency(documents);
const IDFVals = inverseDocumentFrequency(documents);
let TFidfDict = {};
for (const [key, value] of Object.entries(TFVals)){
if (key in IDFVals){
TFidfDict[key] = TFVals[key] * IDFVals[key];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment