如何在斯坦福大学NLP产生情感树库



我正在使用stanford nlp库进行情感分析。

现在我想从句子中生成一个树库

输入句子:"有效但过于敏感的传记片"

输出树库:(2(3(3效)(2 but))(1(1(1太湿)(2传记)))

有人可以告诉我如何做吗?谢谢所有。

如果您从github获取最新代码并使用该版本:https://github.com/stanfordnlp/corenlp

您可以发出此命令:

java -Xmx8g edu.stanford.nlp.sentiment.SentimentPipeline -file example-sentences.txt -output PENNTREES

您将获得这样的输出:

I really liked the movie.
(3 (2 I) (3 (2 really) (3 (3 (3 liked) (2 (2 the) (2 movie))) (2 .))))
I hated the movie.
(1 (2 I) (1 (1 (1 hated) (2 (2 the) (2 movie))) (2 .)))

最新更新