当前位置:   article > 正文

求助(用hanlp对文本进行情感判定出现错误)

求助(用hanlp对文本进行情感判定出现错误)
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.seg.common.Term;
import java.util.*;

public class NaiveBayesSentimentAnalysis {

    private Map<String, Map<String, Double>> conditionalProbabilities; // 条件概率
    private Map<String, Double> priorProbabilities; // 先验概率
    private Set<String> vocabulary; // 词汇表

    public NaiveBayesSentimentAnalysis(Map<String, Map<String, Integer>> wordCountsPerLabel,
                                       Map<String, Integer> labelCounts,
                                       Set<String> vocabulary) {
        conditionalProbabilities = new HashMap<>();
        priorProbabilities = new HashMap<>();
        this.vocabulary = vocabulary;
        train(wordCountsPerLabel, labelCounts);
    }

    // 使用训练好的模型进行情感判定
    public String predict(String document) {
        List<Term> segmentedDocument = HanLP.segment(document);
        Map<String, Double> logPro
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/953960
推荐阅读
相关标签
  

闽ICP备14008679号