2. Watson Services
• Watson services are consumed via REST APIs
• IBM provides Java wrappers for these: https://github.com/watson-
developer-cloud/java-sdk
• Darwino provides consistent access to these APIs in ways that can be used as
beans
• Darwino module dwo-jre-ibm-watson
<bean name="toneAnalyzerFactory" class="com.darwino.ibm.watson.ToneAnalyzerFactory">
<property name="url">https://gateway.watsonplatform.net/tone-analyzer/api</property>
<property name="user">some-unid-string</property>
<property name="password">some-random-password</property>
</bean>
4. Setting Up The Services
• Apps don’t actually need to
be deployed to Bluemix to
consume Watson services
• All that is required is a stub
application on Bluemix with
the services associated with
it – that will give you the
access tokens
5. Example: Social Analyzer
• The Social Analyzer uses Watson’s Tone Analysis to analyze content from
multiple sources
• Analysis is done by a periodic background task, written to find un-analyzed
documents and add in Watson’s results
ToneAnalyzer analyzer = getToneAnalyzerFactory().createToneAnalyzer();
// …
ToneAnalysis analysis = analyzer.getTone(content).execute();
if(analysis != null) {
JsonObject analysisObj = JsonObject.fromJson(analysis.toString());
document.set(PROP_ANALYSIS, analysisObj);
document.save();
}