public virtual void TestMatching()
        {
            b = new SynonymMap.Builder(true);
            const bool keepOrig = false;

            Add("a b", "ab", keepOrig);
            Add("a c", "ac", keepOrig);
            Add("a", "aa", keepOrig);
            Add("b", "bb", keepOrig);
            Add("z x c v", "zxcv", keepOrig);
            Add("x c", "xc", keepOrig);
            SynonymMap map = b.Build();
            Analyzer   a   = new AnalyzerAnonymousInnerClassHelper6(this, map);

            CheckOneTerm(a, "$", "$");
            CheckOneTerm(a, "a", "aa");
            CheckOneTerm(a, "b", "bb");

            AssertAnalyzesTo(a, "a $", new string[] { "aa", "$" }, new int[] { 1, 1 });

            AssertAnalyzesTo(a, "$ a", new string[] { "$", "aa" }, new int[] { 1, 1 });

            AssertAnalyzesTo(a, "a a", new string[] { "aa", "aa" }, new int[] { 1, 1 });

            AssertAnalyzesTo(a, "z x c v", new string[] { "zxcv" }, new int[] { 1 });

            AssertAnalyzesTo(a, "z x c $", new string[] { "z", "xc", "$" }, new int[] { 1, 1, 1 });
        }
예제 #2
0
        public virtual void TestVersion40()
        {
            Analyzer a = new AnalyzerAnonymousInnerClassHelper6(this);

            // U+061C is a new combining mark in 6.3, found using "[[\p{WB:Format}\p{WB:Extend}]&[^\p{Age:6.2}]]"
            // on the online UnicodeSet utility: <http://unicode.org/cldr/utility/list-unicodeset.jsp>
            AssertAnalyzesTo(a, "this is just a t\u061Cst [email protected]", new string[] { "this", "is", "just", "a", "t", "st", "*****@*****.**" });
        }
        public virtual void TestLetterUnicodeHuge()
        {
            Random       random    = Random;
            int          maxLength = 4300; // CharTokenizer.IO_BUFFER_SIZE + fudge
            MockAnalyzer left      = new MockAnalyzer(random, jvmLetter, false);

            left.MaxTokenLength = 255; // match CharTokenizer's max token length
            Analyzer right         = new AnalyzerAnonymousInnerClassHelper6(this);
            int      numIterations = AtLeast(50);

            for (int i = 0; i < numIterations; i++)
            {
                string s = TestUtil.RandomUnicodeString(random, maxLength);
                assertEquals(s, left.GetTokenStream("foo", newStringReader(s)), right.GetTokenStream("foo", newStringReader(s)));
            }
        }
예제 #4
0
        public virtual void TestMockGraphTokenFilterAfterHolesRandom()
        {
            for (int iter = 0; iter < 10 * RANDOM_MULTIPLIER; iter++)
            {
                if (VERBOSE)
                {
                    Console.WriteLine("\nTEST: iter=" + iter);
                }

                // Make new analyzer each time, because MGTF has fixed
                // seed:
                Analyzer a = new AnalyzerAnonymousInnerClassHelper6(this);

                Random random = Random;
                CheckRandomData(random, a, 5, AtLeast(100));
            }
        }
예제 #5
0
        /// <summary>
        /// blast some random strings through the analyzer </summary>
        public virtual void TestRandomStrings()
        {
            int numIterations = AtLeast(5);

            for (int i = 0; i < numIterations; i++)
            {
                WordDelimiterFlags flags = (WordDelimiterFlags)Random.Next(512);
                CharArraySet       protectedWords;
                if (Random.nextBoolean())
                {
                    protectedWords = new CharArraySet(TEST_VERSION_CURRENT, new string[] { "a", "b", "cd" }, false);
                }
                else
                {
                    protectedWords = null;
                }

                Analyzer a = new AnalyzerAnonymousInnerClassHelper6(this, flags, protectedWords);
                CheckRandomData(Random, a, 1000 * RANDOM_MULTIPLIER);
            }
        }
        /// <summary>
        /// blast some random strings through the analyzer </summary>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void testRandomStrings() throws Exception
        public virtual void testRandomStrings()
        {
            int numIterations = atLeast(5);
            for (int i = 0; i < numIterations; i++)
            {
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final int flags = random().nextInt(512);
              int flags = random().Next(512);
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final org.apache.lucene.analysis.util.CharArraySet protectedWords;
              CharArraySet protectedWords;
              if (random().nextBoolean())
              {
            protectedWords = new CharArraySet(TEST_VERSION_CURRENT, new HashSet<>("a", "b", "cd"), false);
              }
              else
              {
            protectedWords = null;
              }

              Analyzer a = new AnalyzerAnonymousInnerClassHelper6(this, flags, protectedWords);
              checkRandomData(random(), a, 1000 * RANDOM_MULTIPLIER);
            }
        }
        /// <summary>
        /// blast some random strings through the analyzer </summary>
        public virtual void TestRandomStrings()
        {
            int numIterations = AtLeast(5);
            for (int i = 0; i < numIterations; i++)
            {
                int flags = Random().Next(512);
                CharArraySet protectedWords;
                if (Random().nextBoolean())
                {
                    protectedWords = new CharArraySet(TEST_VERSION_CURRENT, new string[] { "a", "b", "cd" }, false);
                }
                else
                {
                    protectedWords = null;
                }

                Analyzer a = new AnalyzerAnonymousInnerClassHelper6(this, flags, protectedWords);
                CheckRandomData(Random(), a, 1000 * RANDOM_MULTIPLIER);
            }
        }
예제 #8
0
        public virtual void TestMockGraphTokenFilterAfterHolesRandom()
        {
            for (int iter = 0; iter < 10 * RANDOM_MULTIPLIER; iter++)
            {
                if (VERBOSE)
                {
                    Console.WriteLine("\nTEST: iter=" + iter);
                }

                // Make new analyzer each time, because MGTF has fixed
                // seed:
                Analyzer a = new AnalyzerAnonymousInnerClassHelper6(this);

                Random random = Random();
                CheckRandomData(random, a, 5, AtLeast(100));
            }
        }
예제 #9
0
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void testLetterUnicodeHuge() throws Exception
 public virtual void testLetterUnicodeHuge()
 {
     Random random = random();
     int maxLength = 4300; // CharTokenizer.IO_BUFFER_SIZE + fudge
     MockAnalyzer left = new MockAnalyzer(random, jvmLetter, false);
     left.MaxTokenLength = 255; // match CharTokenizer's max token length
     Analyzer right = new AnalyzerAnonymousInnerClassHelper6(this);
     int numIterations = atLeast(50);
     for (int i = 0; i < numIterations; i++)
     {
       string s = TestUtil.randomUnicodeString(random, maxLength);
       assertEquals(s, left.tokenStream("foo", newStringReader(s)), right.tokenStream("foo", newStringReader(s)));
     }
 }
예제 #10
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void testMatching() throws Exception
        public virtual void testMatching()
        {
            b = new SynonymMap.Builder(true);
            const bool keepOrig = false;
            add("a b", "ab", keepOrig);
            add("a c", "ac", keepOrig);
            add("a", "aa", keepOrig);
            add("b", "bb", keepOrig);
            add("z x c v", "zxcv", keepOrig);
            add("x c", "xc", keepOrig);
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final SynonymMap map = b.build();
            SynonymMap map = b.build();
            Analyzer a = new AnalyzerAnonymousInnerClassHelper6(this, map);

            checkOneTerm(a, "$", "$");
            checkOneTerm(a, "a", "aa");
            checkOneTerm(a, "b", "bb");

            assertAnalyzesTo(a, "a $", new string[] {"aa", "$"}, new int[] {1, 1});

            assertAnalyzesTo(a, "$ a", new string[] {"$", "aa"}, new int[] {1, 1});

            assertAnalyzesTo(a, "a a", new string[] {"aa", "aa"}, new int[] {1, 1});

            assertAnalyzesTo(a, "z x c v", new string[] {"zxcv"}, new int[] {1});

            assertAnalyzesTo(a, "z x c $", new string[] {"z", "xc", "$"}, new int[] {1, 1, 1});
        }
        public virtual void TestMatching()
        {
            b = new SynonymMap.Builder(true);
            const bool keepOrig = false;
            Add("a b", "ab", keepOrig);
            Add("a c", "ac", keepOrig);
            Add("a", "aa", keepOrig);
            Add("b", "bb", keepOrig);
            Add("z x c v", "zxcv", keepOrig);
            Add("x c", "xc", keepOrig);
            SynonymMap map = b.Build();
            Analyzer a = new AnalyzerAnonymousInnerClassHelper6(this, map);

            CheckOneTerm(a, "$", "$");
            CheckOneTerm(a, "a", "aa");
            CheckOneTerm(a, "b", "bb");

            AssertAnalyzesTo(a, "a $", new string[] { "aa", "$" }, new int[] { 1, 1 });

            AssertAnalyzesTo(a, "$ a", new string[] { "$", "aa" }, new int[] { 1, 1 });

            AssertAnalyzesTo(a, "a a", new string[] { "aa", "aa" }, new int[] { 1, 1 });

            AssertAnalyzesTo(a, "z x c v", new string[] { "zxcv" }, new int[] { 1 });

            AssertAnalyzesTo(a, "z x c $", new string[] { "z", "xc", "$" }, new int[] { 1, 1, 1 });
        }
 public virtual void TestVersion40()
 {
     Analyzer a = new AnalyzerAnonymousInnerClassHelper6(this);
     // U+061C is a new combining mark in 6.3, found using "[[\p{WB:Format}\p{WB:Extend}]&[^\p{Age:6.2}]]"
     // on the online UnicodeSet utility: <http://unicode.org/cldr/utility/list-unicodeset.jsp>
     AssertAnalyzesTo(a, "this is just a t\u061Cst [email protected]", new string[] { "this", "is", "just", "a", "t", "st", "*****@*****.**" });
 }