Exemplo n.º 1
0
        /// <summary>
        /// Calculates the modified unigram precision score as described in section 2.1 of the paper.
        /// </summary>
        /// <param name="reference">The reference as a string.</param>
        /// <param name="candidate">The candidate as a string.</param>
        /// <returns>The Modified n-gram precision score.</returns>
        public double ModifiedUnigramPrecision(string reference, string candidate)
        {
            var referenceCollector = new NGramCollector(reference);
            var candidateCollector = new NGramCollector(candidate);

            return(ModifiedUnigramPrecision(referenceCollector, candidateCollector));
        }
Exemplo n.º 2
0
        public void TestGetTriGramNoPunctuation()
        {
            var testString = "this, is a test string";
            var expected   = new [] { "this is a", "is a test", "a test string" };
            var collector  = new NGramCollector(testString, 3, stripPunctuation: true);
            var result     = collector.Collect();

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 3
0
        public void TestGetTriGrams()
        {
            var testString = "this is a test string";
            var expected   = new [] { "this is a", "is a test", "a test string" };
            var collector  = new NGramCollector(testString, 3);
            var result     = collector.Collect();

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 4
0
        public void TestSimplePrecision()
        {
            var candidate = "the the the the the the the.";
            var ref1      = "The cat is on the mat.";

            var candidateCollector = new NGramCollector(candidate);
            var refCollector       = new NGramCollector(ref1);

            var    bleu      = new BleuScore();
            var    precision = bleu.ModifiedUnigramPrecision(refCollector, candidateCollector);
            double expected  = 2.0d / 7.0d;

            Assert.AreEqual(expected, precision);
        }