分享

IBM Bluemix: Watson Services on Bluemix

 jnstyle 2015-07-15
 Recently I came to know some of the details of IBM Watson, Watson is a Cognitive Computing System, it understands the question we provide to it, and provides us relevant answers based on the context of the question, along with the level of Confidence it has on that answer.  It is also capable of learning with our assistance.

With Watson Question and Answer Service (BETA) available in IBM Bluemix, and with ways to interact with it, it was easy to develop a Sample, please try this sample at AnswerOurQuestion

Currently the topics Healthcare and Travel are exposed here and you could provide relevant questions to obtain answers.  Infact, the Question and Answer service is so good, that you could provide a rating to each answer based on the answer's relevance.

The below code snippet shows us how the interaction with the Watson service takes place.   The input is in the form of a JSONObject.  We provide the question, the number of answers we require through a JSON object.   The username and password required to login can be obtained from the VCAP_SERVICES of the Question and Answer Service.  The dataset is the topic (which is referred to here as the corpus)  to which our question is related.

The answer is a String which is also in JSON format.
 
        JSONObject questionJson = new JSONObject();
        questionJson.put("questionText",question);
        JSONObject evidenceRequest = new JSONObject();
        evidenceRequest.put("items",5);
        questionJson.put("evidenceRequest",evidenceRequest);

        JSONObject postData = new JSONObject();
        postData.put("question",questionJson);

        try {
            Executor executor = Executor.newInstance().auth(username, password);
            URI serviceURI = new URI(baseURL+ "/v1/question/"+dataset).normalize();
            String answersJson = executor.execute(Request.Post(serviceURI)
                .addHeader("Accept", "application/json")
                .addHeader("X-SyncTimeout", "30")
                .bodyString(postData.toString(), ContentType.APPLICATION_JSON)
                ).returnContent().asString();

            List<Map<String, String>> answers = formatAnswers(answersJson);


Further links to Watson and Watson in Bluemix are given below:
Create a natural language question answering system
Change Hello to Watson

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约