我正在编写一个Java程序,需要分析一小块文本(3-4句话,新闻文章),以了解他们的情感。我只需要知道这篇文章通常是正面的、负面的还是中性的。
例如,理想的情况是将以下内容归类为“正面”:
亚马逊的Kindle电子书销量猛增。Amazon.com说,比起平装版和精装本加起来,它的Kindle电子阅读设备的电子书销量更多。
我所需要的是一个非常简单和快速的第三方解决方案,我可以在我的程序中使用。它不一定总是完全准确的。许可证等并不是一个问题,只要有可能跟踪解决方案。
到目前为止,我已经找到了一个潜在的很好的解决方案,AlchemyAPI,但我很难真正使用它。
如果有人以前遇到过这个问题,并且知道一个特别好/容易的解决方案,或者是一个非常好的教程,我将非常感激:)
(我也为这个问题中缺少代码表示歉意。)
发布于 2011-05-20 14:58:35
我刚刚测试了AlchemyAPI。这并不是百分之百准确,但我想这种技术还处于初级阶段。
您需要注册(免费)才能获得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
这些投入是:
我得到了以下输出(中性情绪,而不是预期的积极情绪):
<?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>发布于 2018-04-26 03:37:11
2018年有更多的情感分析API!:-)根据您需要的特性或文本的语言,您可以使用其中之一:
对于语言支持,特性和价格比较我要提到这篇文章。。
发布于 2018-11-28 13:10:46
如果你需要更好的情感分析准确性,你可以自己训练你的模型,比如https://text2data.com/Sentiment-Model-Training
https://stackoverflow.com/questions/6073109
复制相似问题