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是你要做分析的文件,按行分析,每行最后需要有句号或者?!等符号,代表句子结束,如果没有分析将不准确
    • 输出结果如下:
    • Standford CoreNLP--Sentiment Analysis初探
  • Eclipse运行方式:
    •   在源代码里找到:edu.stanford.nlp.sentiment.SentimentPipeline.java,在运行配置里设置参数:-file C:/parserdata/foo.txt
    • 运行代码即可,结果会出现在Eclipse Console中输出

相关文章:

  • 2021-12-15
  • 2022-01-13
  • 2021-04-01
  • 2021-03-31
  • 2021-11-06
  • 2021-10-19
  • 2021-12-09
  • 2021-09-24
猜你喜欢
  • 2021-12-10
  • 2021-11-24
  • 2022-01-14
  • 2021-12-23
  • 2022-12-23
  • 2021-11-26
  • 2021-09-30
相关资源
相似解决方案