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
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.