情感分析API/工具,适用于Java

7
我正在编写一个Java程序,需要分析小段文本(3-4句话,新闻文章的转述)的情感。我只需要知道文章是否一般为积极、消极或中性。
例如,以下内容最好被归类为积极:
"Kindle电子书销量飙升,亚马逊公司表示,它正在销售更多的电子书,比平装和精装纸质版加起来还要多。"
我只需要一个非常简单且易于实现的第三方解决方案,可以在我的程序中使用。它不必总是完全准确。许可证等不是问题,只要可以试用该解决方案即可。
到目前为止,我已经找到了一个潜在的好解决方案AlchemyAPI,但我很难真正使用它。


如果有人之前遇到过这个问题,并知道特别好/简便的解决方法,或者知道一个非常好的教程,我将不胜感激 :-)


(我很抱歉这个问题中缺少代码。)

1
很抱歉这个问题中缺少代码。有关问题的缺失,您有什么评论吗? ;) - Andrew Thompson
4个回答

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. sentiment=1 2. showSourceText=1 3. text(我使用了您的示例文本,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=<插入您的API密钥>&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? - Dinoop Nair
我也在寻找同样的答案。你能告诉我如何用Java编写它吗? - Amitabh Ranjan


0

2018年有更多的情感分析API!:-) 根据您需要的功能或文本语言,您可以使用以下之一:

  • Algorithmia的LexSent by hyindao
  • Algorithmia的Sentiment Analysis by mtman
  • Algorithmia的Sentiment Analysis by nlu
  • Algorithmia的Social Sentiment Analysis by nlu
  • Amazon Web Services Comprehend
  • Aylien Text Analysis
  • Boson NLP Sentiment Analysis
  • Google Cloud Natural Language
  • IBM Watson NLU
  • Meaning Cloud Sentiment Analysis
  • Microsoft Cognitive Services Text Analytics
  • Repustate Text Analytics
  • Salesforce Einstein Language
  • Twinword Sentiment Analysis
  • TheSay PreCeive

关于语言支持、功能和价格比较,我会参考这篇文章


-1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接