Example #1
0
        public double TFIDFSimilarity(Document <T> query, Corpus <T> corpus)
        {
            double[] queryWeights    = corpus.Select(term => query.TFIDF(term, corpus)).ToArray();
            double[] documentWeights = corpus.Select(term => TFIDF(term, corpus)).ToArray();

            var vectorSpaceModel = new VectorSpaceModel(queryWeights, documentWeights);

            return(vectorSpaceModel.CalculateCosineSimilarity());
        }
Example #2
0
 public double TFIDF(T term, Corpus <T> corpus)
 {
     return(TFIDF(term, corpus, AugmentedTermFrequency));
 }
Example #3
0
 public double TFIDF(T term, Corpus <T> corpus, Func <T, double> termFrequencyFunction)
 {
     return(termFrequencyFunction(term) * corpus.IDF(term));
 }