0

我正在尝试在 IBM Watson 平台的自然语言分类器服务中调用 deleteClassifier() 方法,操作完成但不会删除分类器。这是我的代码和输出:

代码:

NaturalLanguageClassifier service = new NaturalLanguageClassifier();
service.setUsernameAndPassword("xxxxxxx", "yyyyyyy");

System.out.println("Before deleting: ");
Classifier classifier;
classifier = service.getClassifier("90e7acx197-nlc-38920").execute();
System.out.println(classifier);

service.deleteClassifier("90e7acx197-nlc-38920");

System.out.println("After deleting: ");
classifier = service.getClassifier("90e7acx197-nlc-38920").execute();
System.out.println(classifier);

输出:

删除前:

Apr 18, 2017 7:16:08 PM okhttp3.internal.platform.Platform log
INFO: --> GET https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/90e7acx197-nlc-38920 http/1.1
Apr 18, 2017 7:16:08 PM okhttp3.internal.platform.Platform log
INFO: <-- 200 OK https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/90e7acx197-nlc-38920 (167ms, unknown-length body)

{
  "classifier_id": "90e7acx197-nlc-38920",
  "language": "en",
  "name": "TutorialClassifier",
  "status": "Available",
  "created": "2017-04-18T01:26:14.630",
  "status_description": "The classifier instance is now available and is ready to take classifier requests.",
  "url": "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/90e7acx197-nlc-38920"
}

删除后:

Apr 18, 2017 7:16:08 PM okhttp3.internal.platform.Platform log
INFO: --> GET https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/90e7acx197-nlc-38920 http/1.1
Apr 18, 2017 7:16:09 PM okhttp3.internal.platform.Platform log
INFO: <-- 200 OK https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/90e7acx197-nlc-38920 (142ms, unknown-length body)

{
  "classifier_id": "90e7acx197-nlc-38920",
  "language": "en",
  "name": "TutorialClassifier",
  "status": "Available",
  "created": "2017-04-18T01:26:14.630",
  "status_description": "The classifier instance is now available and is ready to take classifier requests.",
  "url": "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/90e7acx197-nlc-38920"
}

已接_JAVA_OPTIONS: -Xmx512M -Xms512M

我在这里做错了吗?

4

1 回答 1

0

需要使用 deleteClassifier 调用.execute()

添加.execute()

service.deleteClassifier("90e7acx197-nlc-38920");

以下方法将删除您的分类器

service.deleteClassifier("90e7acx197-nlc-38920").execute();
于 2017-04-30T20:12:26.717 回答