Beispiel #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());
        }
Beispiel #2
0
        public double AugumentedSimilarity(Document <T> query, IList <Document <T> > corpus)
        {
            List <T> vocabulary = corpus.SelectMany(term => term).Distinct().ToList();

            double[] queryWeights    = vocabulary.Select(query.AugmentedTermFrequency).ToArray();
            double[] documentWeights = vocabulary.Select(AugmentedTermFrequency).ToArray();

            var vectorSpaceModel = new VectorSpaceModel(queryWeights, documentWeights);

            return(vectorSpaceModel.CalculateCosineSimilarity());
        }