【问题标题】:IBM Watson - Natural Language Classifier service (Java SDK) - deleteClassifier() method does not delete the classifierIBM Watson - 自然语言分类器服务 (Java SDK) - deleteClassifier() 方法不会删除分类器
【发布时间】:2017-04-18 18:35:32
【问题描述】:

我正在尝试调用 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

我在这里做错了吗?

【问题讨论】:

    标签: java ibm-watson nl-classifier


    【解决方案1】:

    deleteClassifier 需要使用.execute() 调用

    添加.execute()

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

    下面的方法会删除你的分类器

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

    【讨论】:

    • 非常感谢。这行得通。阅读您的回复后,我回到文档并意识到我错过了“.execute()”部分,或者我可能以某种方式登陆了旧文档。无论如何,再次感谢您的帮助。
    猜你喜欢
    • 2017-12-23
    • 2016-03-11
    • 1970-01-01
    • 2017-08-11
    • 2015-10-10
    • 1970-01-01
    • 2016-07-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多