phpibm-cloud

IBM Watson NLU API: Unsupported Language Error for Non-English Text


I'm using IBM's Natural Language Understanding (NLU) API on IBM Cloud to analyze text. The API works fine when the text is in English, but I encounter an "unsupported language" error when trying to process text in languages other than English, such as German ('de').

Here's the code snippet I'm using to make the API request:

$url = "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/instances/****/v1/analyze?version=2017-02-27";
$token = "apikey:****************";
$token = base64_encode($token);
$language = 'de'; // Trying to set the language to German

$bodyArray = [
    "text" => $text,
    "features" => [
        "syntax" => [
            "sentences" => true
        ]
    ],
    "language" => $language
];

$body = json_encode($bodyArray);
$headers = [
    'Authorization' => 'Basic ' . $token,
    "Content-Type" => "application/json"
];

$client = new Client();
$request = new GuzzleHttpRequest('POST', $url, $headers, $body);
$response = $client->send($request);
$response = $response->getBody()->getContents();

Problem:

When I set the language parameter to 'de' (or any other non-English language), I receive an error stating that the language is unsupported.

My Questions:

Does IBM Watson NLU API support languages other than English for syntax analysis? If yes, what am I missing in my request setup? Are there specific languages that need to be configured differently? Any guidance on resolving this issue would be greatly appreciated.


Solution

  • The NLU feature for syntax / sentences seems to be an experimental feature and hence only supported for the English language. That feature is not listed in the language support for the GA features.

    Thus, I assume it is not working by design.