2011-05-20 33 views
7

我正在编写一个Java程序,需要分析他们的情绪的小块文本(3-4句,新闻文章转述)。我只需要知道文章是否总体上是积极的,消极的或中立的。虔诚分析API /工具,对于Java

例如,下面将理想被归类为阳性:

Kindle电子书销量飙升亚马逊。 Amazon.com说,这是销售更多的 电子书为其Kindle的电子阅读 比平装本和设备结合

所有我需要的是一个非常简单和快速实施第三方解决方案 精装印刷版,即我可以在我的程序中使用。它不一定是完全准确的。许可证等不是问题,只要有可能追踪解决方案。

到目前为止,我已经找到了一个潜在的良好解决方案,AlchemyAPI,但我正在努力实际使用它。


如果有人遇到过这个问题,并特别好的/简单的解决方案,或者一个非常好的教程的人都知道,我会:-)


非常感谢(另外,我对此问题中缺少代码表示歉意。)

+1

“我为缺乏道歉的代码在这个问题上。“有关缺少问题的任何评论? ;) – 2011-05-23 19:54:25

回答

15

我刚刚测试了AlchemyAPI。这不是100%准确的,但我想这种技术仍处于初级阶段。

您需要注册(免费)才能获得api密钥。

这里的示例用法:http://access.alchemyapi.com/calls/text/TextGetTextSentiment?apikey=<insert your api key>&sentiment=1&showSourceText=1&text=Kindle%20e-book%20sales%20soar%20for%20Amazon.%20Amazon.com%20says%20it%20is%20selling%20more%20e-books%20for%20its%20Kindle%20electronic%20reading%20device%20than%20paperback%20and%20hardback%20print%20editions%20combined

的输入是:

  1. 情绪= 1
  2. showSourceText = 1
  3. 文本(我用你的示例文本,URI编码)

我得到了以下输出(中性情绪,而不是预期的积极情绪):

<?xml version="1.0" encoding="UTF-8"?> 
<results>  
    <status>OK</status>  
    <usage>By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html</usage>  
    <url></url>  
    <language>english</language>  
    <text>Kindle e-book sales soar for Amazon. Amazon.com says it is selling more e-books for its Kindle electronic reading device than paperback and hardback print editions combined</text>  
    <docSentiment>  
     <type>neutral</type>  
    </docSentiment>  
</results> 


另一个示例用法:http://access.alchemyapi.com/calls/text/TextGetTextSentiment?apikey=<insert your api key>&sentiment=1&showSourceText=1&text=kindle%20is%20amazing

和输出:

<?xml version="1.0" encoding="UTF-8"?>  
<results>  
    <status>OK</status>  
    <usage>By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html</usage>  
    <url></url>  
    <language>english</language>  
    <text>kindle is amazing</text>  
    <docSentiment>  
     <type>positive</type>  
     <score>0.283568</score>  
    </docSentiment>  
</results> 
+1

我如何在java中使用alchemyAPI? – 2014-05-05 18:29:13

+0

我也在寻找相同的。你能告诉我如何用java编写它吗? – 2014-08-21 17:07:17