Skip to content

Instantly share code, notes, and snippets.

View dreamerns's full-sized avatar

Nikola Novakovic dreamerns

View GitHub Profile
@dreamerns
dreamerns / TFIDF.java
Last active July 7, 2020 22:27
TF-IDF in Java
// search returns array of matching docs ranked by tf-idf score
// aka term frequency * inverse document frequency
//
// tf = # of occurences of term in document / # of words in document
// idf = log ( # of documents / # of documents with term )
// tf-idf = tf * idf
// multi-term tf-idf = sum of tf-idf scores (per document)
import java.util.Arrays;