Standford CoreNLP--Sentiment Analysis初探

Stanford CoreNLP功能之一是Sentiment Analysis(情感分析),可以标识出语句的正面或者负面情绪,包括:Positive,Neutral,Negative三个值。

 运行有两种方式:命令行和Eclipse运行,两种方式都需要编译源代码,源码可以在http://stanfordnlp.github.io/CoreNLP/index.html 下载,对于命令行方式也可以只下载jar包,推荐下载源码,编译方式在其主页上有讲,这里就不做赘述。

  • 命令行方式:
    •   编译完后在命令行运行:java -cp "*" -mx1g edu.stanford.nlp.sentiment.SentimentPipeline -file foo.txt ,foo.txt是你要做分析的文件,按行分析,每行最后需要有句号或者?!等符号,代表句子结束,如果没有分析将不准确
    • 输出结果如下:
  • Eclipse运行方式:
    •   在源代码里找到:edu.stanford.nlp.sentiment.SentimentPipeline.java,在运行配置里设置参数:-file C:/parserdata/foo.txt
    • 运行代码即可,结果会出现在Eclipse Console中输出
原文地址:https://www.cnblogs.com/csts/p/5464955.html