I am working with Watson NLU and trying to sentiment analysis on some text. The problem is that some text is too small for it to detect what language it is (E.g: Excellent service).Is there a way for me to specify that if language detection isn't possible, it should consider it English?
The snippet of my NLU (Java) is this:
SentimentOptions sentiment = new SentimentOptions.Builder()
.targets(targets)
.document(true)
.build();
Features features = new Features.Builder()
.sentiment(sentiment)
.build();
AnalyzeOptions parameters = new AnalyzeOptions.Builder()
.text(text)
.features(features)
.build();
AnalysisResults response = service
.analyze(parameters)
.execute();
String mySentiment = response.getSentiment().getDocument().getLabel();
According to the Official API Reference documentation, you need to specify the
language
parameter in yourPOST
request.See more about these parameters on Watson Developer Cloud - Github - Java SDK.
Explanation of the API Reference - NLU:
Example of how it works:
parameters.json file example:
The cURL example:
Probably your example (you did not specify your programming language, so):