1

Following is the java code for visual recognition in IBM watson and it works perfectly fine as English as default o/p language.

Now, I want to set Spanish as o/p language. How to do that? How to set the parameter?

VisualRecognition service = new VisualRecognition(VisualRecognition.VERSION_DATE_2016_05_20);
service.setApiKey(key);
ClassifyImagesOptions options = new ClassifyImagesOptions.Builder()
.images(new File(path))
.build();
VisualClassification result = service.classify(options).execute();
Sayuri Mizuguchi
  • 5,250
  • 3
  • 26
  • 53
djac
  • 187
  • 19

2 Answers2

1

You should add acceptLanguage to your options building:

ClassifyImagesOptions options = new ClassifyImagesOptions.Builder()
.acceptLanguage("es")
.images(new File(path))
.build()
ipbd
  • 524
  • 3
  • 16
  • acceptLanguage("es") This option is not available. What might be the reason? Error:(819, 29) error: cannot find symbol method acceptLanguage(String) – djac Sep 28 '17 at 08:58
  • Are you sure you are using the recent version of SDK? Because current one doesn't have class ClassifyImagesOption, it has class ClassifyOptions instead. – ipbd Sep 28 '17 at 15:37
  • update: yes, a week ago they issued the version 4.0.0 where ClassifyImagesOption class was removed in favour of ClassifyOptions. So you will have to bump up the Watson SDK version on your project. – ipbd Sep 28 '17 at 15:44
1

See what languages you can set and follow this example:

.acceptLanguage(ES)

acceptLanguage wait for one String according your error and the JavaSDK, and if you saw the JavaSDK in this line, you can see that has String with each language that this service accept currently.

Reference: Watson Developer Cloud Java SDK and here.

Sayuri Mizuguchi
  • 5,250
  • 3
  • 26
  • 53