use of com.ibm.watson.assistant.v1.model.Value in project java-sdk by watson-developer-cloud.
the class Assistant method getSynonym.
/**
* Get entity value synonym.
*
* <p>Get information about a synonym of an entity value.
*
* @param getSynonymOptions the {@link GetSynonymOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Synonym}
*/
public ServiceCall<Synonym> getSynonym(GetSynonymOptions getSynonymOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getSynonymOptions, "getSynonymOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", getSynonymOptions.workspaceId());
pathParamsMap.put("entity", getSynonymOptions.entity());
pathParamsMap.put("value", getSynonymOptions.value());
pathParamsMap.put("synonym", getSynonymOptions.synonym());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getSynonym");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
if (getSynonymOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(getSynonymOptions.includeAudit()));
}
ResponseConverter<Synonym> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Synonym>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Value in project java-sdk by watson-developer-cloud.
the class Assistant method updateSynonym.
/**
* Update entity value synonym.
*
* <p>Update an existing entity value synonym with new text.
*
* <p>If you want to update multiple synonyms with a single API call, consider using the **[Update
* entity](#update-entity)** or **[Update entity value](#update-entity-value)** method instead.
*
* @param updateSynonymOptions the {@link UpdateSynonymOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link Synonym}
*/
public ServiceCall<Synonym> updateSynonym(UpdateSynonymOptions updateSynonymOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(updateSynonymOptions, "updateSynonymOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", updateSynonymOptions.workspaceId());
pathParamsMap.put("entity", updateSynonymOptions.entity());
pathParamsMap.put("value", updateSynonymOptions.value());
pathParamsMap.put("synonym", updateSynonymOptions.synonym());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateSynonym");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
if (updateSynonymOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(updateSynonymOptions.includeAudit()));
}
final JsonObject contentJson = new JsonObject();
if (updateSynonymOptions.newSynonym() != null) {
contentJson.addProperty("synonym", updateSynonymOptions.newSynonym());
}
builder.bodyJson(contentJson);
ResponseConverter<Synonym> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Synonym>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.assistant.v1.model.Value in project dna by leifeld.
the class Sql method getShallowStatements.
/**
* Get a shallow representation of all statements in a specific document for
* the purpose of painting the statements in the text. For this purpose,
* variable contents, date, coder name etc. are unnecessary. This speeds up
* the retrieval.
*
* @param documentId ID of the document for which statements are retrieved.
* @return Array list of statements.
*/
public ArrayList<Statement> getShallowStatements(int documentId) {
String query = "SELECT S.ID, S.Start, S.Stop, S.StatementTypeId, " + "T.Label AS StatementTypeLabel, T.Red AS StatementTypeRed, " + "T.Green AS StatementTypeGreen, T.Blue AS StatementTypeBlue, " + "S.Coder, C.Red AS CoderRed, C.Green AS CoderGreen, C.Blue AS CoderBlue " + "FROM STATEMENTS S LEFT JOIN CODERS C ON C.ID = S.Coder " + "LEFT JOIN STATEMENTTYPES T ON T.ID = S.StatementTypeId " + "WHERE S.DocumentId = ? ORDER BY Start ASC;";
ArrayList<Statement> statements = new ArrayList<Statement>();
try (Connection conn = ds.getConnection();
PreparedStatement s = conn.prepareStatement(query)) {
ResultSet r;
s.setInt(1, documentId);
r = s.executeQuery();
while (r.next()) {
Statement statement = new Statement(r.getInt("ID"), r.getInt("Start"), r.getInt("Stop"), r.getInt("StatementTypeId"), r.getString("StatementTypeLabel"), new Color(r.getInt("StatementTypeRed"), r.getInt("StatementTypeGreen"), r.getInt("StatementTypeBlue")), r.getInt("Coder"), "", new Color(r.getInt("CoderRed"), r.getInt("CoderGreen"), r.getInt("CoderBlue")), new ArrayList<Value>(), documentId, null, null);
statements.add(statement);
}
LogEvent l = new LogEvent(Logger.MESSAGE, "[SQL] " + statements.size() + " statement(s) have been retrieved for Document " + documentId + ".", statements.size() + " statement(s) have been retrieved for for Document " + documentId + ".");
Dna.logger.log(l);
} catch (SQLException e) {
LogEvent l = new LogEvent(Logger.WARNING, "[SQL] Failed to retrieve statements for Document " + documentId + ".", "Attempted to retrieve all statements for Document " + documentId + " from the database, but something went wrong. You should double-check if the statements are all shown!", e);
Dna.logger.log(l);
}
return statements;
}
Aggregations