gpt4 book ai didi

java - 斯坦福 coreNLP 无需拆分句子的情感

转载 作者:行者123 更新时间:2023-11-30 03:07:07 25 4
gpt4 key购买 nike

我正在向 coreNLP 的情绪标记器提供文件。我已经将文件分成单独的句子,因此希望每个文件返回一个标签。如何让java命令返回一个标签。

该命令如下所示 java -cp "*"-mx5g edu.stanford.nlp.sentiment.SentimentPipeline -stdin 并输出如下:

Annotation pipeline timing information:
TokenizerAnnotator: 0.0 sec.
WordsToSentencesAnnotator: 0.0 sec.
TOTAL: 0.0 sec. for 8 tokens at 296.3 tokens/sec.
Pipeline setup: 0.0 sec.
Total time for StanfordCoreNLP pipeline: 8.7 sec.

C:\stanford-corenlp-full-2015-04-20>java -cp "*" -mx5g edu.stanford.nlp.sentiment.SentimentPipeline -stdin
Adding annotator tokenize
TokenizerAnnotator: No tokenizer type provided. Defaulting to PTBTokenizer.
Adding annotator ssplit
Adding annotator parse
Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ... done [0.4 sec].
Adding annotator sentiment
Reading in text from stdin.
Please enter one sentence per line.
Processing will end when EOF is reached.

Computer is fun. Not too fun.
Positive
Neutral

如何通过删除标点符号使输出成为类似于我在下面所做的操作的单个标记:

Computer is fun Not too fun.
Positive

看来我应该能够轻松地做到这一点,因为有 -ssplit.isOneSentence 并且据我了解,情感标记器使用 ssplit 但我不知道如何修改我的命令以合并它(我已阅读 command line documentation )。

最佳答案

SentimentPipeline 中似乎存在错误,因为当您使用 -stdin 选项时,它不应该在一行内分割句子。我现在修复了这个问题,但除非您编译自己的版本,否则在我们发布下一版本的 CoreNLP 之前这不会对您有帮助。

但是还有一种替代(可能是更好)的方法来使用 CoreNLP 管道获取句子的情感标签。

以下命令运行与您的命令相同的代码,但同时它允许您为各个注释器指定更多选项(包括 -ssplit.eolonly 选项)。

java -cp "*" -mx5g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators "tokenize,ssplit,parse,sentiment" -ssplit.eolonly

关于java - 斯坦福 coreNLP 无需拆分句子的情感,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34483978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com