
com.blackbirdai.client.model.Correction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of search-client Show documentation
Show all versions of search-client Show documentation
Java client for Blackbird search API
The newest version!
package com.blackbirdai.client.model;
import com.fasterxml.jackson.databind.JsonNode;
import javax.annotation.Nullable;
/**
* Container for spelling correction result.
*/
public class Correction {
private final String cq;
private final Type type;
public Correction(String cq, Type type) {
this.cq = cq;
this.type = type;
}
/**
* Returns spelling corrected query.
*/
public String getCq() {
return cq;
}
/**
* Returns level of confidence for this spelling correction.
*/
public Type getType() {
return type;
}
@Nullable
static Correction parseJson(JsonNode json) {
if (json.get("cq") == null || json.get("type") == null) {
return null;
} else {
try {
Type cqType = Type.valueOf(json.get("type").asText().toUpperCase());
return new Correction(json.get("cq").asText(), cqType);
} catch (Exception e) {
return null;
}
}
}
public enum Type {
STRONG,
WEAK
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy