2011-05-20 83 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