Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractClassifier中的enableProbability方法似乎有BUG #1423

Closed
1 task done
orangeclk opened this issue Feb 14, 2020 · 1 comment
Closed
1 task done

AbstractClassifier中的enableProbability方法似乎有BUG #1423

orangeclk opened this issue Feb 14, 2020 · 1 comment
Assignees
Labels

Comments

@orangeclk
Copy link

Describe the bug
用户调用enableProbability(boolean enable)后,不管传入的值是true还是false,都不会影响到configProbabilityEnabled的值,从而导致 if (configProbabilityEnabled) MathUtility.normalizeExp(predictionScores); 永远执行。

建议将

    @Override
    public IClassifier enableProbability(boolean enable)
    {
        return this;
    }

修改为

    @Override
    public IClassifier enableProbability(boolean enable)
    {
        configProbabilityEnabled = enable;
        return this;
    }

Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.

    public Map<String, Double> test() throws IOException {
        IClassifier iClassifier = new NaiveBayesClassifier(trainOrLoadModel()).enableProbability(false);;
        return iClassifier.predict("test java demo"); 
}

Describe the current behavior
enableProbability方法失效。

Expected behavior
enableProbability方法生效。

System information

  • Windows 0
  • Java 1.8
  • HanLP 1.7.5

Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

  • I've completed this form and searched the web for solutions.
@hankcs
Copy link
Owner

hankcs commented Feb 14, 2020

感谢反馈,已经修复,请参考上面的commit。
如果还有问题,欢迎重开issue。

@hankcs hankcs closed this as completed Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants