2

Unfortunately I can't properly tag this question since tags for AlchemyLanguage don't already exist. I'm trying to retrieve multiple extracts from Watson using a combined call. Issuing calls for individual data extracts works as expected, but when I attempt to setup params for a combined call only null is returned for each extract. According to the examples utilizing JSON it seems that 'extract':'sentiment' is the required pairing.

None of these calls work:

params.put(AlchemyLanguage.EXTRACT, AlchemyLanguage.SENTIMENT);
params.put(AlchemyLanguage.EXTRACT, AlchemyEndPoints.AlchemyAPI.SENTIMENT);
params.put(AlchemyLanguage.EXTRACT, DocumentSentiment.class);
params.put(AlchemyLanguage.TARGET, AlchemyEndPoints.AlchemyAPI.SENTIMENT);
params.put(AlchemyLanguage.TARGET, DocumentSentiment.class);
params.put(AlchemyLanguage.TARGET, AlchemyLanguage.SENTIMENT);

CombinedResults results=service.getCombinedResults(params).execute();
System.out.println(results.getSentiment());

null

ralphearle
  • 1,696
  • 13
  • 18
m1k3t
  • 93
  • 1
  • 2
  • 7

1 Answers1

0

You need to use the extract parameter as key and list the functions you want to use.

AlchemyLanguage service = new AlchemyLanguage();
service.setApiKey("API_KEY")
Map<String, Object> params = new HashMap<String, Object>();

params.put(AlchemyLanguage.EXTRACT, "authors,concepts,dates,doc-emotion,entities,feeds,keywords,pub-date,relations,typed-rels,doc-sentiment,taxonomy,title");

CombinedResults results=service.getCombinedResults(params).execute();
System.out.println(results);

For more information on how to configure each of the functions listed in the extract parameter see the API Reference.

German Attanasio
  • 22,217
  • 7
  • 47
  • 63