Skip to content

Commit

Permalink
fix(assistant-v2): add answers to searchResult
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkowa committed Sep 14, 2021
1 parent f44fa49 commit 8d53d6c
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.google.gson.annotations.SerializedName;
import com.ibm.cloud.sdk.core.service.model.GenericModel;
import java.util.List;

/** SearchResult. */
public class SearchResult extends GenericModel {
Expand All @@ -27,6 +28,7 @@ public class SearchResult extends GenericModel {
protected String title;
protected String url;
protected SearchResultHighlight highlight;
protected List<SearchResultAnswer> answers;

/**
* Gets the id.
Expand Down Expand Up @@ -99,4 +101,20 @@ public String getUrl() {
public SearchResultHighlight getHighlight() {
return highlight;
}

/**
* Gets the answers.
*
* <p>An array specifying segments of text within the result that were identified as direct
* answers to the search query. Currently, only the single answer with the highest confidence (if
* any) is returned.
*
* <p>**Note:** This property uses the answer finding beta feature, and is available only if the
* search skill is connected to a Discovery v2 service instance.
*
* @return the answers
*/
public List<SearchResultAnswer> getAnswers() {
return answers;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* (C) Copyright IBM Corp. 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.ibm.watson.assistant.v2.model;

import com.ibm.cloud.sdk.core.service.model.GenericModel;

/**
* An object specifing a segment of text that was identified as a direct answer to the search query.
*/
public class SearchResultAnswer extends GenericModel {

protected String text;
protected Double confidence;

/**
* Gets the text.
*
* <p>The text of the answer.
*
* @return the text
*/
public String getText() {
return text;
}

/**
* Gets the confidence.
*
* <p>The confidence score for the answer, as returned by the Discovery service.
*
* @return the confidence
*/
public Double getConfidence() {
return confidence;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2020.
* (C) Copyright IBM Corp. 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -37,5 +37,6 @@ public void testSearchResult() throws Throwable {
assertNull(searchResultModel.getTitle());
assertNull(searchResultModel.getUrl());
assertNull(searchResultModel.getHighlight());
assertNull(searchResultModel.getAnswers());
}
}

0 comments on commit 8d53d6c

Please sign in to comment.