lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [46/50] [abbrv] lucenenet git commit: Added non-random test to help with debugging Suggest.Analyzing.AnalyzingSuggesterTest.TestRandom()
Date Sun, 02 Oct 2016 14:36:04 GMT
Added non-random test to help with debugging Suggest.Analyzing.AnalyzingSuggesterTest.TestRandom()


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/3fa9a782
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/3fa9a782
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/3fa9a782

Branch: refs/heads/master
Commit: 3fa9a7821701207bd41cf65df2e2b4cec0d3cc66
Parents: bd00a5f
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Thu Sep 22 10:05:14 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Oct 2 17:45:10 2016 +0700

----------------------------------------------------------------------
 .../Suggest/Analyzing/AnalyzingSuggesterTest.cs | 53 ++++++++++++++++++++
 1 file changed, 53 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3fa9a782/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
index 44cbee8..41f3beb 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/Analyzing/AnalyzingSuggesterTest.cs
@@ -1045,6 +1045,59 @@ namespace Lucene.Net.Search.Suggest.Analyzing
             }
         }
 
+
+        /// <summary>
+        /// LUCENENET specific test. Added fixed inputs to help with debugging issues found
in TestRandom().
+        /// Not necessarily required per se, but it may come in handy again if the above
test fails.
+        /// </summary>
+        [Test]
+        public void TestFixed()
+        {
+            bool preserveSep = true;
+            int numStopChars = 2;
+            bool preserveHoles = true;
+
+            string token11 = "foo bar foo bar";
+            string token21 = "bar foo orange cat";
+
+            string token12 = "sally sells seashells by the sea shore";
+            string token22 = "peter piper picked a pack of pickled peppers";
+
+            string query1 = "ba";
+            string query2 = "pet";
+
+            // Query 1
+            Analyzer a1 = new MockTokenEatingAnalyzer(numStopChars, preserveHoles);
+            AnalyzingSuggester suggester1 = new AnalyzingSuggester(a1, a1,
+                preserveSep ? AnalyzingSuggester.PRESERVE_SEP : 0, 256, -1, true);
+
+            suggester1.Build(new InputArrayIterator(new Input[] { new Input(token11, 123456),
new Input(token21, 654321) }));
+
+            int topN1 = 4;
+            IList<Lookup.LookupResult> r1 = suggester1.DoLookup(query1, false, topN1);
+
+            assertEquals(1, r1.size());
+
+            assertEquals("bar foo orange cat", r1.ElementAt(0).key);
+            assertEquals(654321, r1.ElementAt(0).value, 0f);
+
+            // Query 2
+            Analyzer a2 = new MockTokenEatingAnalyzer(numStopChars, preserveHoles);
+            AnalyzingSuggester suggester2 = new AnalyzingSuggester(a2, a2,
+                preserveSep ? AnalyzingSuggester.PRESERVE_SEP : 0, 256, -1, true);
+
+            suggester2.Build(new InputArrayIterator(new Input[] { new Input(token12, 1234567),
new Input(token22, 7654321) }));
+
+            int topN2 = 4;
+            IList<Lookup.LookupResult> r2 = suggester2.DoLookup(query2, false, topN2);
+
+            assertEquals(1, r2.size());
+
+            assertEquals("peter piper picked a pack of pickled peppers", r2.ElementAt(0).key);
+            assertEquals(7654321, r2.ElementAt(0).value, 0f);
+        }
+
+
         [Test]
         public void TestMaxSurfaceFormsPerAnalyzedForm()
         {


Mime
View raw message