You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by laimis <gi...@git.apache.org> on 2014/12/07 04:35:44 UTC

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

GitHub user laimis opened a pull request:

    https://github.com/apache/lucenenet/pull/26

    port of lucene-solr/lucene/classification w/o tests

    Port of /lucene/classification/src/java/org/apache/lucene/classification (from lucene_solr_4_8_0 branch).
    
    All the classes were ported in a separate project and solution files were added. Once I get a hang of this, I can port the tests too, just want to make sure I am doing this right.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/laimis/lucenenet classification_port

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/lucenenet/pull/26.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #26
    
----
commit aba955ce29c81a2e943246acb1df7940fe3d7483
Author: Laimonas Simutis <la...@gmail.com>
Date:   2014-12-07T03:23:30Z

    port of lucene-solr/lucene/classification w/o tests

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by geobmx540 <gi...@git.apache.org>.
Github user geobmx540 commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/26#discussion_r21422047
  
    --- Diff: src/Lucene.Net.Classification/Classifier.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 Classifier<T> 
    --- End diff --
    
    rename to IClassifier<T>


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Re: [GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by Laimonas Simutis <la...@gmail.com>.
Do not see a comment synced from github here, but I pushed the fixes for
the items that Itamar and Prescott brought up.

Laimonas

On Sun, Dec 7, 2014 at 7:50 AM, laimis <gi...@git.apache.org> wrote:

> Github user laimis commented on the pull request:
>
>     https://github.com/apache/lucenenet/pull/26#issuecomment-65936340
>
>     Itamar, I emailed a signed ICLA this morning. Let me know if there is
> anything else to do.
>
>
> ---
> If your project is set up for it, you can reply to this email and have your
> reply appear on GitHub as well. If your project does not have this feature
> enabled and wishes so, or if the feature is enabled but not working, please
> contact infrastructure at infrastructure@apache.org or file a JIRA ticket
> with INFRA.
> ---
>

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by laimis <gi...@git.apache.org>.
Github user laimis commented on the pull request:

    https://github.com/apache/lucenenet/pull/26#issuecomment-65936340
  
    Itamar, I emailed a signed ICLA this morning. Let me know if there is anything else to do.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by geobmx540 <gi...@git.apache.org>.
Github user geobmx540 commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/26#discussion_r21422018
  
    --- Diff: src/Lucene.Net.Classification/ClassificationResult.cs ---
    @@ -0,0 +1,64 @@
    +/*
    + * 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
    +{
    +    /// <summary>
    +    /// 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> {
    --- End diff --
    
    Is this missing the `: IComparable<ClassificationResult<T>>` interface?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on the pull request:

    https://github.com/apache/lucenenet/pull/26#issuecomment-67832588
  
    Thanks, pulling this in now. Any chance you could port the tests as well? Simple copy/paste from Java with minor fixes should do, no need for styling there. I'll try getting some guidance on that posted.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by geobmx540 <gi...@git.apache.org>.
Github user geobmx540 commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/26#discussion_r21422007
  
    --- Diff: src/Lucene.Net.Classification/KNearesteighborClassifier.cs ---
    @@ -0,0 +1,150 @@
    +/*
    + * 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;
    --- End diff --
    
    intend


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on the pull request:

    https://github.com/apache/lucenenet/pull/26#issuecomment-65926546
  
    Quick note: `KNearestNeighborClassifier` is misspelled `KNearesteighborClassifier`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/lucenenet/pull/26


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by geobmx540 <gi...@git.apache.org>.
Github user geobmx540 commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/26#discussion_r21422060
  
    --- Diff: src/Lucene.Net.Classification/KNearesteighborClassifier.cs ---
    @@ -0,0 +1,150 @@
    +/*
    + * 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;
    --- End diff --
    
    could probably get rid of the references to `this.` since the private members are prefixed with an underscore


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by geobmx540 <gi...@git.apache.org>.
Github user geobmx540 commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/26#discussion_r21422050
  
    --- Diff: src/Lucene.Net.Classification/KNearesteighborClassifier.cs ---
    @@ -0,0 +1,150 @@
    +/*
    --- End diff --
    
    As Itamar mentioned - filename is spelled incorrectly


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by geobmx540 <gi...@git.apache.org>.
Github user geobmx540 commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/26#discussion_r21422026
  
    --- Diff: src/Lucene.Net.Classification/Classifier.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 Classifier<T> 
    --- End diff --
    
    rename to IClassifier<T>


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by geobmx540 <gi...@git.apache.org>.
Github user geobmx540 commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/26#discussion_r21422022
  
    --- Diff: src/Lucene.Net.Classification/ClassificationResult.cs ---
    @@ -0,0 +1,64 @@
    +/*
    + * 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
    +{
    +    /// <summary>
    +    /// 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> {
    +
    +        private readonly T _assignedClass;
    +        private readonly double _score;
    +
    +        /// <summary>
    +        /// Constructor
    +        /// <param name="assignedClass">assignedClass the class <code>T</code> assigned by a {@link Classifier}</param>
    +        /// <param name="score">score the score for the assignedClass as a <code>double</code></param>
    +        /// </summary>
    +        public ClassificationResult(T assignedClass, double score) 
    +        {
    +            this._assignedClass = assignedClass;
    +            this._score = score;
    +        }
    +
    +        /// <summary>
    +        /// retrieve the result class
    +        /// @return a <code>T</code> representing an assigned class
    +        /// </summary>
    +        public T AssignedClass 
    +        {
    +            get
    +            {
    +                return _assignedClass;
    +            }
    +        }
    +
    +        /// <summary>
    +        /// retrieve the result score
    +        /// @return a <code>double</code> representing a result score
    +        /// </summary>
    +        public double Score
    --- End diff --
    
    The java code has a setter as well as a getter. Is there a reason there is no getter?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by geobmx540 <gi...@git.apache.org>.
Github user geobmx540 commented on the pull request:

    https://github.com/apache/lucenenet/pull/26#issuecomment-65927010
  
    I made a number of comments while looking at the wrong java code - apologies for that. I have removed them and will re-review. 
    
    Java code here: http://svn.apache.org/repos/asf/lucene/dev/branches/lucene_solr_4_8/lucene/classification/src/java/org/apache/lucene/classification/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on the pull request:

    https://github.com/apache/lucenenet/pull/26#issuecomment-65925366
  
    Thanks, will review shortly. Do you have an ICLA with Apache?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Re: [GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by Itamar Syn-Hershko <it...@code972.com>.
Can we integrate EditorConfig to enforce this?

https://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328
On Dec 7, 2014 7:08 AM, "geobmx540" <gi...@git.apache.org> wrote:

> Github user geobmx540 commented on a diff in the pull request:
>
>     https://github.com/apache/lucenenet/pull/26#discussion_r21422005
>
>     --- Diff: src/Lucene.Net.Classification/KNearesteighborClassifier.cs
> ---
>     @@ -0,0 +1,150 @@
>     +/*
>     + * 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;
>     --- End diff --
>
>     indent
>
>
> ---
> If your project is set up for it, you can reply to this email and have your
> reply appear on GitHub as well. If your project does not have this feature
> enabled and wishes so, or if the feature is enabled but not working, please
> contact infrastructure at infrastructure@apache.org or file a JIRA ticket
> with INFRA.
> ---
>

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by geobmx540 <gi...@git.apache.org>.
Github user geobmx540 commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/26#discussion_r21422005
  
    --- Diff: src/Lucene.Net.Classification/KNearesteighborClassifier.cs ---
    @@ -0,0 +1,150 @@
    +/*
    + * 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;
    --- End diff --
    
    indent


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request: port of lucene-solr/lucene/classification ...

Posted by geobmx540 <gi...@git.apache.org>.
Github user geobmx540 commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/26#discussion_r21422024
  
    --- Diff: src/Lucene.Net.Classification/ClassificationResult.cs ---
    @@ -0,0 +1,64 @@
    +/*
    + * 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
    +{
    +    /// <summary>
    +    /// 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> {
    +
    +        private readonly T _assignedClass;
    +        private readonly double _score;
    --- End diff --
    
    _score is not readonly in java (because there is a setter)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---