Stanford coreNLP情绪没有分裂句子

时间:2015-12-27 19:24:34

标签: java stanford-nlp

我有文件,我正在向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)。

1 个答案:

答案 0 :(得分:2)

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

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

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

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