In AlchemyAPI there are these two functions available TextGetTextSentiment
and 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>
:
: