Reputation: 13
I am in the process of switching from the deprecated AlchemyAPI to Natural Language Understanding. I am using the java-SDK 3.7.1. There is almost no documentation on how to use the updated SDK in the GitHub: enter link description here
This is the code from the old AlchemyAPI what works:
AlchemyLanguage service = new AlchemyLanguage();
service.setApiKey(api-key);
Map<String, Object> params = new HashMap<String, Object>();
params.put(AlchemyLanguage.TEXT, my_text);
Entities e = service.getEntities(params).execute();
This is how far I got with the new Natural Language Understanding:
NaturalLanguageUnderstanding understanding = new NaturalLanguageUnderstanding("2017-02-27");
understanding.setUsernameAndPassword("user","pass");
Map<String, String> params = new HashMap<String, String>();
params.put(XXXXX?, my_text);
Entities e = understanding.XXXXX?.execute();
Does anyone know what how to proceed? or fill into the X?
thanks!
Upvotes: 0
Views: 302
Reputation: 38
I was strugglling with the same issue. Luckily IBM has updated the SDK to version 3.7.2 a few hours ago and a bit of information on usage is available at the moment.
NaturalLanguageUnderstanding service = new NaturalLanguageUnderstanding();
service.setUsernameAndPassword("<username>", "<password>");
EntitiesOptions entities = new EntitiesOptions.Builder().sentiment(true).limit(1).build();
Features features = new Features.Builder().entities(entities).build();
AnalyzeOptions parameters = new AnalyzeOptions.Builder().url("www.cnn.com").features(features).build();
AnalysisResults results = service.analyze(parameters).execute();
Use the link to SDK.
Upvotes: 1