You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2016/10/02 10:17:02 UTC

[31/49] lucenenet git commit: Finished implementing ignored Classification.SimpleNaiveBayesClassifierTest.TestNGramUsage()

Finished implementing ignored Classification.SimpleNaiveBayesClassifierTest.TestNGramUsage()


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

Branch: refs/heads/master
Commit: 202c06875743cdec1ba2d8903ee3337479f65354
Parents: c031b60
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sun Sep 11 05:28:54 2016 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Sun Sep 11 05:28:54 2016 +0700

----------------------------------------------------------------------
 .../Lucene.Net.Tests.Classification.csproj      |  4 ++
 .../SimpleNaiveBayesClassifierTest.cs           | 57 ++++++++++----------
 2 files changed, 34 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/202c0687/src/Lucene.Net.Tests.Classification/Lucene.Net.Tests.Classification.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Classification/Lucene.Net.Tests.Classification.csproj b/src/Lucene.Net.Tests.Classification/Lucene.Net.Tests.Classification.csproj
index 2d618e0..4ccf2dc 100644
--- a/src/Lucene.Net.Tests.Classification/Lucene.Net.Tests.Classification.csproj
+++ b/src/Lucene.Net.Tests.Classification/Lucene.Net.Tests.Classification.csproj
@@ -50,6 +50,10 @@
     <Compile Include="Utils\DataSplitterTest.cs" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\Lucene.Net.Analysis.Common\Lucene.Net.Analysis.Common.csproj">
+      <Project>{4add0bbc-b900-4715-9526-d871de8eea64}</Project>
+      <Name>Lucene.Net.Analysis.Common</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Lucene.Net.Classification\Lucene.Net.Classification.csproj">
       <Project>{E067B8BB-D8E7-4040-BEB8-EFF8BB4149BD}</Project>
       <Name>Lucene.Net.Classification</Name>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/202c0687/src/Lucene.Net.Tests.Classification/SimpleNaiveBayesClassifierTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Classification/SimpleNaiveBayesClassifierTest.cs b/src/Lucene.Net.Tests.Classification/SimpleNaiveBayesClassifierTest.cs
index 7f6d3a0..96ff25b 100644
--- a/src/Lucene.Net.Tests.Classification/SimpleNaiveBayesClassifierTest.cs
+++ b/src/Lucene.Net.Tests.Classification/SimpleNaiveBayesClassifierTest.cs
@@ -1,28 +1,32 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
 using Lucene.Net.Analysis;
+using Lucene.Net.Analysis.Core;
+using Lucene.Net.Analysis.Ngram;
+using Lucene.Net.Analysis.Reverse;
 using Lucene.Net.Index;
 using Lucene.Net.Search;
 using Lucene.Net.Util;
 using NUnit.Framework;
+using System.IO;
 
 namespace Lucene.Net.Classification
 {
+    /*
+     * Licensed to the Apache Software Foundation (ASF) under one or more
+     * contributor license agreements.  See the NOTICE file distributed with
+     * this work for additional information regarding copyright ownership.
+     * The ASF licenses this file to You under the Apache License, Version 2.0
+     * (the "License"); you may not use this file except in compliance with
+     * the License.  You may obtain a copy of the License at
+     *
+     *     http://www.apache.org/licenses/LICENSE-2.0
+     *
+     * Unless required by applicable law or agreed to in writing, software
+     * distributed under the License is distributed on an "AS IS" BASIS,
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     * See the License for the specific language governing permissions and
+     * limitations under the License.
+     */
+
     /**
      * Testcase for {@link SimpleNaiveBayesClassifier}
      */
@@ -45,20 +49,19 @@ namespace Lucene.Net.Classification
         }
 
         [Test]
-        [Ignore("Need to figure out what to do with NGramAnalyzer, issues with things in Analysis.Common project")]
         public void TestNGramUsage()
         {
-            //CheckCorrectClassification(new SimpleNaiveBayesClassifier(), TECHNOLOGY_INPUT, TECHNOLOGY_RESULT, new NGramAnalyzer(), textFieldName, categoryFieldName);
+            CheckCorrectClassification(new SimpleNaiveBayesClassifier(), TECHNOLOGY_INPUT, TECHNOLOGY_RESULT, new NGramAnalyzer(), textFieldName, categoryFieldName);
         }
 
-        //private class NGramAnalyzer : Analyzer
-        //{
-        //    public override TokenStreamComponents CreateComponents(String fieldName, TextReader reader)
-        //    {
-        //        Tokenizer tokenizer = new KeywordTokenizer(reader);
-        //        return new TokenStreamComponents(tokenizer, new ReverseStringFilter(TEST_VERSION_CURRENT, new EdgeNGramTokenFilter(TEST_VERSION_CURRENT, new ReverseStringFilter(TEST_VERSION_CURRENT, tokenizer), 10, 20)));
-        //    }
-        //}
+        private class NGramAnalyzer : Analyzer
+        {
+            public override TokenStreamComponents CreateComponents(string fieldName, TextReader reader)
+            {
+                Tokenizer tokenizer = new KeywordTokenizer(reader);
+                return new TokenStreamComponents(tokenizer, new ReverseStringFilter(TEST_VERSION_CURRENT, new EdgeNGramTokenFilter(TEST_VERSION_CURRENT, new ReverseStringFilter(TEST_VERSION_CURRENT, tokenizer), 10, 20)));
+            }
+        }
 
         [Test]
         public void TestPerformance()