Search code examples
javaapiibm-watsonwatson-conversationlanguage-translation

How to solve com.ibm.watson.developer_cloud.service.exception.NotFoundException in IBM Watson?


I am trying to incorporate IBM Watson translation library in my application.

Below is the sample code that i am trying

LanguageTranslator service = new LanguageTranslator();
        service.setUsernameAndPassword("user","password");

        TranslateOptions translateOptions = new TranslateOptions.Builder()
          .addText("नमस्ते")
          .source(Language.HINDI)
          .target(Language.ENGLISH)
          .build();

        TranslationResult result = service.translate(translateOptions)
          .execute();

        System.out.println(result);

When i use source language as Language.HINDI and target as Language.ENGLISH, i am getting the following exception.

Exception in thread "main" com.ibm.watson.developer_cloud.service.exception.NotFoundException: Model not found.
    at com.ibm.watson.developer_cloud.service.WatsonService.processServiceCall(WatsonService.java:415)
    at com.ibm.watson.developer_cloud.service.WatsonService$1.execute(WatsonService.java:174)
    at com.terrierdemo.LanguageTranslatorIBM.main(LanguageTranslatorIBM.java:23)

But for some language combinations(Language.ENGLISH|Language.SPANISH) I am getting expected result. Could anyone help me on this?


Solution

  • From your error description, it is clear that the translator model is not available for your source and target languages. You Check for the available source models using this List Models. I did not see any default model that can translate Hindi to English. You need to create a model for this. Create Model