作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在向 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/
我是一名优秀的程序员,十分优秀!