Example #1
0
        public void IDFTest()
        {
            var doc1 = new Document(new List <string>()
            {
                "АААА", "АААА", "ББББ", "ЗАС"
            });
            var doc2 = new Document(new List <string>()
            {
                "АААА", "АААА", "ББББ", "ББББ", "ББББ"
            });
            var documents = new Dictionary <string, Document>
            {
                ["1"] = doc1,
                ["2"] = doc2
            };
            IDF idfEvaluator = new IDF(documents);

            Assert.AreEqual(Math.Log10((double)documents.Count / 2), idfEvaluator.Evaluate(doc1[0]), eps);
            Assert.AreEqual(Math.Log10((double)documents.Count / 2), idfEvaluator.Evaluate(doc1[2]), eps);
            Assert.AreEqual(Math.Log10((double)documents.Count / 1), idfEvaluator.Evaluate(doc1[3]), eps);
        }