コード例 #1
0
 public virtual void TestBasicAutomata()
 {
     AssertAutomatonHits(0, BasicAutomata.MakeEmpty());
     AssertAutomatonHits(0, BasicAutomata.MakeEmptyString());
     AssertAutomatonHits(2, BasicAutomata.MakeAnyChar());
     AssertAutomatonHits(3, BasicAutomata.MakeAnyString());
     AssertAutomatonHits(2, BasicAutomata.MakeString("doc"));
     AssertAutomatonHits(1, BasicAutomata.MakeChar('a'));
     AssertAutomatonHits(2, BasicAutomata.MakeCharRange('a', 'b'));
     AssertAutomatonHits(2, BasicAutomata.MakeInterval(1233, 2346, 0));
     AssertAutomatonHits(1, BasicAutomata.MakeInterval(0, 2000, 0));
     AssertAutomatonHits(2, BasicOperations.Union(BasicAutomata.MakeChar('a'), BasicAutomata.MakeChar('b')));
     AssertAutomatonHits(0, BasicOperations.Intersection(BasicAutomata.MakeChar('a'), BasicAutomata.MakeChar('b')));
     AssertAutomatonHits(1, BasicOperations.Minus(BasicAutomata.MakeCharRange('a', 'b'), BasicAutomata.MakeChar('a')));
 }
コード例 #2
0
        public virtual void TestIntersect()
        {
            for (int i = 0; i < numIterations; i++)
            {
                string                   reg       = AutomatonTestUtil.RandomRegexp(Random);
                Automaton                automaton = (new RegExp(reg, RegExpSyntax.NONE)).ToAutomaton();
                CompiledAutomaton        ca        = new CompiledAutomaton(automaton, SpecialOperations.IsFinite(automaton), false);
                TermsEnum                te        = MultiFields.GetTerms(reader, "field").Intersect(ca, null);
                Automaton                expected  = BasicOperations.Intersection(termsAutomaton, automaton);
                JCG.SortedSet <BytesRef> found     = new JCG.SortedSet <BytesRef>();
                while (te.Next() != null)
                {
                    found.Add(BytesRef.DeepCopyOf(te.Term));
                }

                Automaton actual = BasicAutomata.MakeStringUnion(found);
                Assert.IsTrue(BasicOperations.SameLanguage(expected, actual));
            }
        }