斯坦福的 CoreNLP 情绪分析工具有多快?

How fast is Stanford's CoreNLP sentiment analysis tool?

  1. 我想知道在相当于大约 100 万条 IMDB 评论的数据集上使用 CoreNLP 情感分析工具 (http://nlp.stanford.edu/sentiment/code.html) 是否可行。

我在网上找不到任何关于平均时间的绝对指标。如果有人能指出有关这些速度统计数据的任何地方,我将不胜感激。

  1. 此外,这就是我正在尝试的 - 看看是否可以仅使用文本来估计电影评级,即通过总结评论中每个句子的分数。我的想法或下面的代码片段中有什么看起来很愚蠢(应该做得更好)吗?我感觉我可能将这个工具用于它不适合的事情,或者我用错了方法。

    public static double getTextSentimentScore(String text){
    Annotation annotation = pipeline.process(text);
    double sum = 0;
    List<CoreMap> sentences = (List<CoreMap>) annotation.get(CoreAnnotations.SentencesAnnotation.class);
    int i = 0;
    for (CoreMap sentence : sentences) {
        String sentiment = sentence.get(SentimentCoreAnnotations.SentimentClass.class);
        int sentimentScore = 0;
        if (sentiment.equals("Very positive"))
            sentimentScore = 5;
        if (sentiment.equals("Positive"))
            sentimentScore = 4;
        if (sentiment.equals("Neutral"))
            sentimentScore = 3;
        if (sentiment.equals("Negative"))
            sentimentScore = 2;
        if (sentiment.equals("Very negative"))
            sentimentScore = 1;
        sum += sentimentScore;
        System.out.println(sentiment + "\t" + sentimentScore);
    }
    return (sum/sentences.size());
    

    }

如果你运行这个命令:

java -Xmx5g -cp "stanford-corenlp-full-2015-12-09/*" edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,parse,sentiment -filelist list-of-sample-docs.txt

最终输出将为您提供计时信息

所以你所要做的就是:

  1. 获取 100 条 IMDB 评论,将它们放入名为 imdb_review_1、imdb_review_2 等的文件中...

  2. 在样本列表中将每个文件名每行一个文件-docs.txts

  3. 运行 该命令和最终输出将显示每个注释器的总时间和经过的总时间