Esempio n. 1
0
        public virtual void TestFindMatches()
        {
            string      text        = "Who is Col. Jibril Rajoub";
            PhraseTable phraseTable = new PhraseTable();

            phraseTable.caseInsensitive = true;
            phraseTable.AddPhrases(phrases);
            IList <PhraseTable.PhraseMatch> matched = phraseTable.FindMatches(text, 2, 5, true);

            NUnit.Framework.Assert.IsTrue(matched != null);
            NUnit.Framework.Assert.AreEqual(2, matched.Count);
        }
Esempio n. 2
0
        public virtual void TestPhraseTable()
        {
            PhraseTable phraseTable = new PhraseTable();

            phraseTable.normalize       = true;
            phraseTable.caseInsensitive = true;
            phraseTable.AddPhrases(phrases);
            IList <PhraseTable.PhraseMatch> matched = phraseTable.FindAllMatches(testText);

            NUnit.Framework.Assert.IsTrue(matched != null);
            NUnit.Framework.Assert.AreEqual(12, matched.Count);
            // Test lookup
            PhraseTable.Phrase p = phraseTable.LookupNormalized("COL.");
            NUnit.Framework.Assert.AreEqual("Col.", p.GetText());
        }
Esempio n. 3
0
        public virtual void TestIterator()
        {
            PhraseTable phraseTable = new PhraseTable();

            phraseTable.caseInsensitive = true;
            phraseTable.AddPhrases(phrases);
            ICollection <string> origPhrases = new HashSet <string>();

            Sharpen.Collections.AddAll(origPhrases, phrases);
            ICollection <string>             iteratedPhrases = new HashSet <string>();
            IEnumerator <PhraseTable.Phrase> iterator        = phraseTable.Iterator();

            while (iterator.MoveNext())
            {
                iteratedPhrases.Add(iterator.Current.GetText());
            }
            ICollection <string> intersection        = CollectionUtils.Intersection(origPhrases, iteratedPhrases);
            ICollection <string> inOrigNotInIterated = CollectionUtils.Diff(origPhrases, intersection);

            NUnit.Framework.Assert.IsTrue("In original but not in iterated: " + inOrigNotInIterated, inOrigNotInIterated.IsEmpty());
            ICollection <string> inIteratedNotInOrig = CollectionUtils.Diff(iteratedPhrases, intersection);

            NUnit.Framework.Assert.IsTrue("In iterated but not in original: " + inIteratedNotInOrig, inIteratedNotInOrig.IsEmpty());
        }