0

In AlchemyAPI there are these two functions available TextGetTextSentimentand TextGetRankedKeywords.

but TextGetTextSentiment gives only sentiments without keywords (which made API come to sentiment conclusion). And TextGetRankedKeywords does not give sentiments.

Is there any API that gives both this information and correlation ?

I tried all these for a sample text. But it did not give required results.

  TextGetRankedNamedEntities
  TextGetRankedConcepts
  TextGetRankedKeywords
  TextGetLanguage
  TextGetCategory
  TextGetTextSentiment 
  TextGetTargetedSentiment
  TextGetRelations     
  TextGetCombined     
  TextGetTaxonomy  

EDIT: As answered by Zach below. Code would look like :-

        AlchemyAPI_KeywordParams param = new AlchemyAPI_KeywordParams();
        param.setSentiment(true);
        doc = alchemyObj.TextGetRankedKeywords(textToAnalyse,param);
        System.out.println(getStringFromDocument(doc));

It provides output like this

:
:
<totalTransactions>2</totalTransactions>
<language>english</language>
<keywords>
    <keyword>
        <relevance>0.938195</relevance>
        <sentiment>
            <type>neutral</type>
        </sentiment>
        <text>OK Madam Mitch</text>
    </keyword>
    <keyword>
        <relevance>0.915145</relevance>
        <sentiment>
            <score>0.492952</score>
            <type>positive</type>
        </sentiment>
        <text>Clarence Knight</text>
    </keyword>
    :
    :
Kaushik Lele
  • 6,439
  • 13
  • 50
  • 76

1 Answers1

0

TextGetRankedKeywords has a sentiment parameter that allows you to perform targeted sentiment analysis on each keyword that is extracted. You simply need to set sentiment=1.

Zach Walchuk
  • 261
  • 1
  • 4
  • How is sentiment given by TextGetTextSentiment is related to individual sentiments given by TextGetRankedKeywords(with sentiment flag=1) ? Is it just sum/average etc? – Kaushik Lele Jun 16 '15 at 08:38
  • No, it is calculated separately. TextGetTextSentiment looks at the entire text you submit and uses this for its calculations, whereas TextGetRankedKeywords looks at the context around each keyword to determine sentiment. The results won't necessarily be correlated, although if you have a lot of negative keywords the entire text is likely negative as well. – Zach Walchuk Jun 20 '15 at 00:56
  • Thanks @Zach. Can you please also check other question http://stackoverflow.com/questions/30954978/is-there-way-to-influence-alchemyapi-sentiment-analysis – Kaushik Lele Jun 20 '15 at 14:18