lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [2/3] lucenenet git commit: fixes based on feedback (rename classes, fix indents, remove 'this.')
Date Mon, 22 Dec 2014 13:10:02 GMT
fixes based on feedback (rename classes, fix indents, remove 'this.')


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

Branch: refs/heads/master
Commit: 583627a12799609a4fd1ceed5487805ebd7dc8b6
Parents: aba955c
Author: Laimonas Simutis <laimis@gmail.com>
Authored: Sun Dec 7 07:41:02 2014 -0500
Committer: Laimonas Simutis <laimis@gmail.com>
Committed: Sun Dec 7 07:41:02 2014 -0500

----------------------------------------------------------------------
 .../ClassificationResult.cs                     |   7 +-
 src/Lucene.Net.Classification/Classifier.cs     |  65 --------
 src/Lucene.Net.Classification/IClassifier.cs    |  65 ++++++++
 .../KNearestNeighborClassifier.cs               | 151 +++++++++++++++++++
 .../KNearesteighborClassifier.cs                | 150 ------------------
 .../Lucene.Net.Classification.csproj            |   4 +-
 .../SimpleNaiveBayesClassifier.cs               |  18 +--
 7 files changed, 231 insertions(+), 229 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/583627a1/src/Lucene.Net.Classification/ClassificationResult.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Classification/ClassificationResult.cs b/src/Lucene.Net.Classification/ClassificationResult.cs
index 356ec7e..1db3ed0 100644
--- a/src/Lucene.Net.Classification/ClassificationResult.cs
+++ b/src/Lucene.Net.Classification/ClassificationResult.cs
@@ -21,7 +21,8 @@ namespace Lucene.Net.Classification
     /// The result of a call to {@link Classifier#assignClass(String)} holding an assigned
class of type <code>T</code> and a score.
     /// @lucene.experimental
     /// </summary>
-    public class ClassificationResult<T> {
+    public class ClassificationResult<T>
+    {
 
         private readonly T _assignedClass;
         private readonly double _score;
@@ -33,8 +34,8 @@ namespace Lucene.Net.Classification
         /// </summary>
         public ClassificationResult(T assignedClass, double score) 
         {
-            this._assignedClass = assignedClass;
-            this._score = score;
+            _assignedClass = assignedClass;
+            _score = score;
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/583627a1/src/Lucene.Net.Classification/Classifier.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Classification/Classifier.cs b/src/Lucene.Net.Classification/Classifier.cs
deleted file mode 100644
index 6ffca79..0000000
--- a/src/Lucene.Net.Classification/Classifier.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.
- */
-
-namespace Lucene.Net.Classification
-{
-    using Lucene.Net.Analysis;
-    using Lucene.Net.Index;
-    using Lucene.Net.Search;
-    using System;
-
-    /// <summary>
-    /// A classifier, see <code>http://en.wikipedia.org/wiki/Classifier_(mathematics)</code>,
which assign classes of type
-    /// <code>T</code>
-    /// @lucene.experimental
-    /// </summary>
-    public interface Classifier<T> 
-    {
-        /// <summary>
-        /// Assign a class (with score) to the given text String
-        /// </summary>
-        /// <param name="text">a String containing text to be classified</param>
-        /// <returns>a {ClassificationResult} holding assigned class of type <code>T</code>
and score</returns>
-        ClassificationResult<T> AssignClass(String text);
-
-        /// <summary>
-        /// * Train the classifier using the underlying Lucene index
-        /// </summary>
-        /// <param name="analyzer"> the analyzer used to tokenize / filter the unseen
text</param>
-        /// <param name="atomicReader">the reader to use to access the Lucene index</param>
-        /// <param name="classFieldName">the name of the field containing the class
assigned to documents</param>
-        /// <param name="textFieldName">the name of the field used to compare documents</param>
-        void Train(AtomicReader atomicReader, String textFieldName, String classFieldName,
Analyzer analyzer);
-
-        /// <summary>Train the classifier using the underlying Lucene index</summary>
-        /// <param name="analyzer">the analyzer used to tokenize / filter the unseen
text</param>
-        /// <param name="atomicReader">the reader to use to access the Lucene index</param>
-        /// <param name="classFieldName">the name of the field containing the class
assigned to documents</param>
-        /// <param name="query">the query to filter which documents use for training</param>
-        /// <param name="textFieldName">the name of the field used to compare documents</param>
-        void Train(AtomicReader atomicReader, String textFieldName, String classFieldName,
Analyzer analyzer, Query query);
-
-        /// <summary>Train the classifier using the underlying Lucene index</summary>
-        /// <param name="analyzer">the analyzer used to tokenize / filter the unseen
text</param>
-        /// <param name="atomicReader">the reader to use to access the Lucene index</param>
-        /// <param name="classFieldName">the name of the field containing the class
assigned to documents</param>
-        /// <param name="query">the query to filter which documents use for training</param>
-        /// <param name="textFieldNames">the names of the fields to be used to compare
documents</param>
-        void Train(AtomicReader atomicReader, String[] textFieldNames, String classFieldName,
Analyzer analyzer,
-                   Query query);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/583627a1/src/Lucene.Net.Classification/IClassifier.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Classification/IClassifier.cs b/src/Lucene.Net.Classification/IClassifier.cs
new file mode 100644
index 0000000..2e05173
--- /dev/null
+++ b/src/Lucene.Net.Classification/IClassifier.cs
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+namespace Lucene.Net.Classification
+{
+    using Lucene.Net.Analysis;
+    using Lucene.Net.Index;
+    using Lucene.Net.Search;
+    using System;
+
+    /// <summary>
+    /// A classifier, see <code>http://en.wikipedia.org/wiki/Classifier_(mathematics)</code>,
which assign classes of type
+    /// <code>T</code>
+    /// @lucene.experimental
+    /// </summary>
+    public interface IClassifier<T>
+    {
+        /// <summary>
+        /// Assign a class (with score) to the given text String
+        /// </summary>
+        /// <param name="text">a String containing text to be classified</param>
+        /// <returns>a {ClassificationResult} holding assigned class of type <code>T</code>
and score</returns>
+        ClassificationResult<T> AssignClass(String text);
+
+        /// <summary>
+        /// * Train the classifier using the underlying Lucene index
+        /// </summary>
+        /// <param name="analyzer"> the analyzer used to tokenize / filter the unseen
text</param>
+        /// <param name="atomicReader">the reader to use to access the Lucene index</param>
+        /// <param name="classFieldName">the name of the field containing the class
assigned to documents</param>
+        /// <param name="textFieldName">the name of the field used to compare documents</param>
+        void Train(AtomicReader atomicReader, String textFieldName, String classFieldName,
Analyzer analyzer);
+
+        /// <summary>Train the classifier using the underlying Lucene index</summary>
+        /// <param name="analyzer">the analyzer used to tokenize / filter the unseen
text</param>
+        /// <param name="atomicReader">the reader to use to access the Lucene index</param>
+        /// <param name="classFieldName">the name of the field containing the class
assigned to documents</param>
+        /// <param name="query">the query to filter which documents use for training</param>
+        /// <param name="textFieldName">the name of the field used to compare documents</param>
+        void Train(AtomicReader atomicReader, String textFieldName, String classFieldName,
Analyzer analyzer, Query query);
+
+        /// <summary>Train the classifier using the underlying Lucene index</summary>
+        /// <param name="analyzer">the analyzer used to tokenize / filter the unseen
text</param>
+        /// <param name="atomicReader">the reader to use to access the Lucene index</param>
+        /// <param name="classFieldName">the name of the field containing the class
assigned to documents</param>
+        /// <param name="query">the query to filter which documents use for training</param>
+        /// <param name="textFieldNames">the names of the fields to be used to compare
documents</param>
+        void Train(AtomicReader atomicReader, String[] textFieldNames, String classFieldName,
Analyzer analyzer,
+                   Query query);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/583627a1/src/Lucene.Net.Classification/KNearestNeighborClassifier.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Classification/KNearestNeighborClassifier.cs b/src/Lucene.Net.Classification/KNearestNeighborClassifier.cs
new file mode 100644
index 0000000..e400254
--- /dev/null
+++ b/src/Lucene.Net.Classification/KNearestNeighborClassifier.cs
@@ -0,0 +1,151 @@
+/*
+ * 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.
+ */
+
+namespace Lucene.Net.Classification
+{
+    using Lucene.Net.Analysis;
+    using Lucene.Net.Index;
+    using Lucene.Net.Queries.Mlt;
+    using Lucene.Net.Search;
+    using Lucene.Net.Util;
+    using System;
+    using System.Collections.Generic;
+    using System.IO;
+
+    /// <summary>
+    /// A k-Nearest Neighbor classifier (see <code>http://en.wikipedia.org/wiki/K-nearest_neighbors</code>)
based
+    /// on {@link MoreLikeThis}
+    ///
+    /// @lucene.experimental
+    /// </summary>
+    public class KNearestNeighborClassifier : IClassifier<BytesRef>
+    {
+
+        private MoreLikeThis _mlt;
+        private String[] _textFieldNames;
+        private String _classFieldName;
+        private IndexSearcher _indexSearcher;
+        private readonly int _k;
+        private Query _query;
+
+        private int _minDocsFreq;
+        private int _minTermFreq;
+
+        /// <summary>Create a {@link Classifier} using kNN algorithm</summary>
+        /// <param name="k">the number of neighbors to analyze as an <code>int</code></param>
+        public KNearestNeighborClassifier(int k)
+        {
+            _k = k;
+        }
+
+        /// <summary>Create a {@link Classifier} using kNN algorithm</summary>
+        /// <param name="k">the number of neighbors to analyze as an <code>int</code></param>
+        /// <param name="minDocsFreq">the minimum number of docs frequency for MLT
to be set with {@link MoreLikeThis#setMinDocFreq(int)}</param>
+        /// <param name="minTermFreq">the minimum number of term frequency for MLT
to be set with {@link MoreLikeThis#setMinTermFreq(int)}</param>
+        public KNearestNeighborClassifier(int k, int minDocsFreq, int minTermFreq)
+        {
+            _k = k;
+            _minDocsFreq = minDocsFreq;
+            _minTermFreq = minTermFreq;
+        }
+
+        public ClassificationResult<BytesRef> AssignClass(String text)
+        {
+            if (_mlt == null)
+            {
+                throw new IOException("You must first call Classifier#train");
+            }
+
+            BooleanQuery mltQuery = new BooleanQuery();
+            foreach (String textFieldName in _textFieldNames)
+            {
+                mltQuery.Add(new BooleanClause(_mlt.Like(new StringReader(text), textFieldName),
BooleanClause.Occur.SHOULD));
+            }
+            Query classFieldQuery = new WildcardQuery(new Term(_classFieldName, "*"));
+            mltQuery.Add(new BooleanClause(classFieldQuery, BooleanClause.Occur.MUST));
+            if (_query != null)
+            {
+                mltQuery.Add(_query, BooleanClause.Occur.MUST);
+            }
+            TopDocs topDocs = _indexSearcher.Search(mltQuery, _k);
+            return SelectClassFromNeighbors(topDocs);
+        }
+
+        private ClassificationResult<BytesRef> SelectClassFromNeighbors(TopDocs topDocs)
+        {
+            // TODO : improve the nearest neighbor selection
+            Dictionary<BytesRef, int> classCounts = new Dictionary<BytesRef, int>();
+
+            foreach (ScoreDoc scoreDoc in topDocs.ScoreDocs)
+            {
+                BytesRef cl = new BytesRef(_indexSearcher.Doc(scoreDoc.Doc).GetField(_classFieldName).StringValue);
+                int count = classCounts[cl];
+                if (classCounts.ContainsKey(cl))
+                {
+                    classCounts[cl] = count + 1;
+                }
+                else
+                {
+                    classCounts.Add(cl, 1);
+                }
+            }
+            double max = 0;
+            BytesRef assignedClass = new BytesRef();
+            foreach (KeyValuePair<BytesRef, int> entry in classCounts)
+            {
+                int count = entry.Value;
+                if (count > max)
+                {
+                    max = count;
+                    assignedClass = (BytesRef)entry.Key.Clone();
+                }
+            }
+            double score = max / (double) _k;
+            return new ClassificationResult<BytesRef>(assignedClass, score);
+        }
+
+        public void Train(AtomicReader atomicReader, String textFieldName, String classFieldName,
Analyzer analyzer)
+        {
+            Train(atomicReader, textFieldName, classFieldName, analyzer, null);
+        }
+
+
+        public void Train(AtomicReader atomicReader, String textFieldName, String classFieldName,
Analyzer analyzer, Query query)
+        {
+            Train(atomicReader, new String[]{textFieldName}, classFieldName, analyzer, query);
+        }
+
+        public void Train(AtomicReader atomicReader, String[] textFieldNames, String classFieldName,
Analyzer analyzer, Query query)
+        {
+            _textFieldNames = textFieldNames;
+            _classFieldName = classFieldName;
+            _mlt = new MoreLikeThis(atomicReader);
+            _mlt.Analyzer = analyzer;
+            _mlt.FieldNames = _textFieldNames;
+            _indexSearcher = new IndexSearcher(atomicReader);
+            if (_minDocsFreq > 0)
+            {
+                _mlt.MinDocFreq = _minDocsFreq;
+            }
+            if (_minTermFreq > 0)
+            {
+                _mlt.MinTermFreq = _minTermFreq;
+            }
+            _query = query;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/583627a1/src/Lucene.Net.Classification/KNearesteighborClassifier.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Classification/KNearesteighborClassifier.cs b/src/Lucene.Net.Classification/KNearesteighborClassifier.cs
deleted file mode 100644
index c83301e..0000000
--- a/src/Lucene.Net.Classification/KNearesteighborClassifier.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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.
- */
-
-namespace Lucene.Net.Classification
-{
-    using Lucene.Net.Analysis;
-    using Lucene.Net.Index;
-    using Lucene.Net.Queries.Mlt;
-    using Lucene.Net.Search;
-    using Lucene.Net.Util;
-    using System;
-    using System.Collections.Generic;
-    using System.IO;
-
-    /// <summary>
-    /// A k-Nearest Neighbor classifier (see <code>http://en.wikipedia.org/wiki/K-nearest_neighbors</code>)
based
-    /// on {@link MoreLikeThis}
-    /// 
-    /// @lucene.experimental
-    /// </summary>
-    public class KNearestNeighborClassifier : Classifier<BytesRef> 
-    {
-
-        private MoreLikeThis _mlt;
-        private String[] _textFieldNames;
-        private String _classFieldName;
-        private IndexSearcher _indexSearcher;
-        private readonly int _k;
-        private Query _query;
-
-        private int _minDocsFreq;
-        private int _minTermFreq;
-
-        /// <summary>Create a {@link Classifier} using kNN algorithm</summary>
-        /// <param name="k">the number of neighbors to analyze as an <code>int</code></param>
-        public KNearestNeighborClassifier(int k) 
-        {
-        this._k = k;
-        }
-
-        /// <summary>Create a {@link Classifier} using kNN algorithm</summary>
-        /// <param name="k">the number of neighbors to analyze as an <code>int</code></param>
-        /// <param name="minDocsFreq">the minimum number of docs frequency for MLT
to be set with {@link MoreLikeThis#setMinDocFreq(int)}</param>
-        /// <param name="minTermFreq">the minimum number of term frequency for MLT
to be set with {@link MoreLikeThis#setMinTermFreq(int)}</param>
-        public KNearestNeighborClassifier(int k, int minDocsFreq, int minTermFreq) 
-        {
-        this._k = k;
-        this._minDocsFreq = minDocsFreq;
-        this._minTermFreq = minTermFreq;
-        }
-
-        public ClassificationResult<BytesRef> AssignClass(String text)
-        {
-            if (_mlt == null) 
-            {
-                throw new IOException("You must first call Classifier#train");
-            }
-
-            BooleanQuery mltQuery = new BooleanQuery();
-            foreach (String textFieldName in _textFieldNames) 
-            {
-                mltQuery.Add(new BooleanClause(_mlt.Like(new StringReader(text), textFieldName),
BooleanClause.Occur.SHOULD));
-            }
-            Query classFieldQuery = new WildcardQuery(new Term(_classFieldName, "*"));
-            mltQuery.Add(new BooleanClause(classFieldQuery, BooleanClause.Occur.MUST));
-            if (_query != null) {
-                mltQuery.Add(_query, BooleanClause.Occur.MUST);
-            }
-            TopDocs topDocs = _indexSearcher.Search(mltQuery, _k);
-            return SelectClassFromNeighbors(topDocs);
-        }
-
-        private ClassificationResult<BytesRef> SelectClassFromNeighbors(TopDocs topDocs)

-        {
-            // TODO : improve the nearest neighbor selection
-            Dictionary<BytesRef, int> classCounts = new Dictionary<BytesRef, int>();
-
-            foreach (ScoreDoc scoreDoc in topDocs.ScoreDocs) 
-            {
-                BytesRef cl = new BytesRef(_indexSearcher.Doc(scoreDoc.Doc).GetField(_classFieldName).StringValue);
-                int count = classCounts[cl];
-                if (classCounts.ContainsKey(cl))
-                {
-                    classCounts[cl] = count + 1;
-                } 
-                else 
-                {
-                    classCounts.Add(cl, 1);
-                }
-            }
-            double max = 0;
-            BytesRef assignedClass = new BytesRef();
-            foreach (KeyValuePair<BytesRef, int> entry in classCounts) 
-            {
-                int count = entry.Value;
-                if (count > max) 
-                {
-                    max = count;
-                    assignedClass = (BytesRef)entry.Key.Clone();
-                }
-            }
-            double score = max / (double) _k;
-            return new ClassificationResult<BytesRef>(assignedClass, score);
-        }
-
-        public void Train(AtomicReader atomicReader, String textFieldName, String classFieldName,
Analyzer analyzer) 
-        {
-            Train(atomicReader, textFieldName, classFieldName, analyzer, null);
-        }
-
-
-        public void Train(AtomicReader atomicReader, String textFieldName, String classFieldName,
Analyzer analyzer, Query query) 
-        {
-            Train(atomicReader, new String[]{textFieldName}, classFieldName, analyzer, query);
-        }
-
-        public void Train(AtomicReader atomicReader, String[] textFieldNames, String classFieldName,
Analyzer analyzer, Query query)
-        {
-            this._textFieldNames = textFieldNames;
-            this._classFieldName = classFieldName;
-            _mlt = new MoreLikeThis(atomicReader);
-            _mlt.Analyzer = analyzer;
-            _mlt.FieldNames = _textFieldNames;
-            _indexSearcher = new IndexSearcher(atomicReader);
-            if (_minDocsFreq > 0) 
-            {
-                _mlt.MinDocFreq = _minDocsFreq;
-            }
-            if (_minTermFreq > 0) 
-            {
-                _mlt.MinTermFreq = _minTermFreq;
-            }
-            this._query = query;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/583627a1/src/Lucene.Net.Classification/Lucene.Net.Classification.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Classification/Lucene.Net.Classification.csproj b/src/Lucene.Net.Classification/Lucene.Net.Classification.csproj
index e0bf2e9..8d31ed5 100644
--- a/src/Lucene.Net.Classification/Lucene.Net.Classification.csproj
+++ b/src/Lucene.Net.Classification/Lucene.Net.Classification.csproj
@@ -40,8 +40,8 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ClassificationResult.cs" />
-    <Compile Include="Classifier.cs" />
-    <Compile Include="KNearesteighborClassifier.cs" />
+    <Compile Include="IClassifier.cs" />
+    <Compile Include="KNearestNeighborClassifier.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="SimpleNaiveBayesClassifier.cs" />
   </ItemGroup>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/583627a1/src/Lucene.Net.Classification/SimpleNaiveBayesClassifier.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Classification/SimpleNaiveBayesClassifier.cs b/src/Lucene.Net.Classification/SimpleNaiveBayesClassifier.cs
index 0980d58..a045c80 100644
--- a/src/Lucene.Net.Classification/SimpleNaiveBayesClassifier.cs
+++ b/src/Lucene.Net.Classification/SimpleNaiveBayesClassifier.cs
@@ -31,7 +31,7 @@ namespace Lucene.Net.Classification
     ///
     /// @lucene.experimental
     /// </summary>
-    public class SimpleNaiveBayesClassifier : Classifier<BytesRef> 
+    public class SimpleNaiveBayesClassifier : IClassifier<BytesRef>
     {
         private AtomicReader _atomicReader;
         private String[] _textFieldNames;
@@ -57,18 +57,18 @@ namespace Lucene.Net.Classification
 
         public void Train(AtomicReader atomicReader, String[] textFieldNames, String classFieldName,
Analyzer analyzer, Query query)
         {
-            this._atomicReader = atomicReader;
-            this._indexSearcher = new IndexSearcher(this._atomicReader);
-            this._textFieldNames = textFieldNames;
-            this._classFieldName = classFieldName;
-            this._analyzer = analyzer;
-            this._query = query;
-            this._docsWithClassSize = CountDocsWithClass();
+            _atomicReader = atomicReader;
+            _indexSearcher = new IndexSearcher(_atomicReader);
+            _textFieldNames = textFieldNames;
+            _classFieldName = classFieldName;
+            _analyzer = analyzer;
+            _query = query;
+            _docsWithClassSize = CountDocsWithClass();
         }
 
         private int CountDocsWithClass() 
         {
-            int docCount = MultiFields.GetTerms(this._atomicReader, this._classFieldName).DocCount;
+            int docCount = MultiFields.GetTerms(_atomicReader, _classFieldName).DocCount;
             if (docCount == -1) 
             { // in case codec doesn't support getDocCount
                 TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();


Mime
View raw message