index
int64 | repo_id
string | file_path
string | content
string |
|---|---|---|---|
0
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv/AscendClientImpl.java
|
package ai.evolv;
import ai.evolv.exceptions.AscendKeyError;
import ai.evolv.generics.GenericClass;
import com.google.gson.JsonArray;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class AscendClientImpl implements AscendClient {
private static final Logger LOGGER = LoggerFactory.getLogger(AscendClientImpl.class);
private final EventEmitter eventEmitter;
private final CompletableFuture<JsonArray> futureAllocations;
private final ExecutionQueue executionQueue;
private final Allocator allocator;
private final AscendAllocationStore store;
private final boolean previousAllocations;
private final AscendParticipant participant;
AscendClientImpl(AscendConfig config,
EventEmitter emitter,
CompletableFuture<JsonArray> futureAllocations,
Allocator allocator,
boolean previousAllocations,
AscendParticipant participant) {
this.store = config.getAscendAllocationStore();
this.executionQueue = config.getExecutionQueue();
this.eventEmitter = emitter;
this.futureAllocations = futureAllocations;
this.allocator = allocator;
this.previousAllocations = previousAllocations;
this.participant = participant;
}
@Override
public <T> T get(String key, T defaultValue) {
try {
if (futureAllocations == null) {
return defaultValue;
}
// this is blocking
JsonArray allocations = futureAllocations.get();
if (!Allocator.allocationsNotEmpty(allocations)) {
return defaultValue;
}
GenericClass<T> cls = new GenericClass(defaultValue.getClass());
T value = new Allocations(allocations, store).getValueFromAllocations(key,
cls.getMyType(), participant);
if (value == null) {
throw new AscendKeyError("Got null when retrieving key " +
"from allocations.");
}
return value;
} catch (AscendKeyError e) {
LOGGER.debug("Unable to retrieve the treatment. Returning " +
"the default.", e);
return defaultValue;
} catch (Exception e) {
LOGGER.error("An error occurred while retrieving the treatment. Returning " +
"the default.", e);
return defaultValue;
}
}
@Override
public <T> void subscribe(String key, T defaultValue, AscendAction<T> function) {
Execution execution = new Execution<>(key, defaultValue, function, participant, store);
if (previousAllocations) {
try {
JsonArray allocations = store.get(participant.getUserId());
execution.executeWithAllocation(allocations);
} catch (AscendKeyError e) {
LOGGER.debug("Unable to retrieve the value of %s from the allocation.",
execution.getKey());
execution.executeWithDefault();
} catch (Exception e) {
LOGGER.error("There was an error when applying the stored treatment.", e);
}
}
Allocator.AllocationStatus allocationStatus = allocator.getAllocationStatus();
if (allocationStatus == Allocator.AllocationStatus.FETCHING) {
executionQueue.enqueue(execution);
return;
} else if (allocationStatus == Allocator.AllocationStatus.RETRIEVED) {
try {
JsonArray allocations = store.get(participant.getUserId());
execution.executeWithAllocation(allocations);
return;
} catch (AscendKeyError e) {
LOGGER.debug(String.format("Unable to retrieve" +
" the value of %s from the allocation.", execution.getKey()), e);
} catch (Exception e) {
LOGGER.error("There was an error applying the subscribed method.", e);
}
}
execution.executeWithDefault();
}
@Override
public void emitEvent(String key, Double score) {
this.eventEmitter.emit(key, score);
}
@Override
public void emitEvent(String key) {
this.eventEmitter.emit(key);
}
@Override
public void confirm() {
Allocator.AllocationStatus allocationStatus = allocator.getAllocationStatus();
if (allocationStatus == Allocator.AllocationStatus.FETCHING) {
allocator.sandBagConfirmation();
} else if (allocationStatus == Allocator.AllocationStatus.RETRIEVED) {
eventEmitter.confirm(store.get(participant.getUserId()));
}
}
@Override
public void contaminate() {
Allocator.AllocationStatus allocationStatus = allocator.getAllocationStatus();
if (allocationStatus == Allocator.AllocationStatus.FETCHING) {
allocator.sandBagContamination();
} else if (allocationStatus == Allocator.AllocationStatus.RETRIEVED) {
eventEmitter.contaminate(store.get(participant.getUserId()));
}
}
}
|
0
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv/AscendConfig.java
|
package ai.evolv;
public class AscendConfig {
static final String DEFAULT_HTTP_SCHEME = "https";
static final String DEFAULT_DOMAIN = "participants.evolv.ai";
static final String DEFAULT_API_VERSION = "v1";
private static final int DEFAULT_ALLOCATION_STORE_SIZE = 1000;
private final String httpScheme;
private final String domain;
private final String version;
private final String environmentId;
private final AscendAllocationStore ascendAllocationStore;
private final AscendParticipant participant;
private final HttpClient httpClient;
private final ExecutionQueue executionQueue;
private AscendConfig(String httpScheme, String domain, String version,
String environmentId,
AscendAllocationStore ascendAllocationStore,
AscendParticipant participant,
HttpClient httpClient) {
this.httpScheme = httpScheme;
this.domain = domain;
this.version = version;
this.environmentId = environmentId;
this.ascendAllocationStore = ascendAllocationStore;
this.participant = participant;
this.httpClient = httpClient;
this.executionQueue = new ExecutionQueue();
}
public static Builder builder(String environmentId, HttpClient httpClient) {
return new Builder(environmentId, httpClient);
}
String getHttpScheme() {
return httpScheme;
}
String getDomain() {
return domain;
}
String getVersion() {
return version;
}
String getEnvironmentId() {
return environmentId;
}
AscendAllocationStore getAscendAllocationStore() {
return ascendAllocationStore;
}
AscendParticipant getAscendParticipant() {
return participant;
}
HttpClient getHttpClient() {
return this.httpClient;
}
ExecutionQueue getExecutionQueue() {
return this.executionQueue;
}
public static class Builder {
private int allocationStoreSize = DEFAULT_ALLOCATION_STORE_SIZE;
private String httpScheme = DEFAULT_HTTP_SCHEME;
private String domain = DEFAULT_DOMAIN;
private String version = DEFAULT_API_VERSION;
private AscendAllocationStore allocationStore;
private AscendParticipant participant;
private String environmentId;
private HttpClient httpClient;
/**
* Responsible for creating an instance of AscendClientImpl.
* <p>
* Builds an instance of the AscendClientImpl. The only required parameter is the
* customer's environment id.
* </p>
* @param environmentId unique id representing a customer's environment
*/
Builder(String environmentId, HttpClient httpClient) {
this.environmentId = environmentId;
this.httpClient = httpClient;
}
/**
* Sets the domain of the underlying ascendParticipant api.
* @param domain the domain of the ascendParticipant api
* @return AscendClientBuilder class
*/
public Builder setDomain(String domain) {
this.domain = domain;
return this;
}
/**
* Version of the underlying ascendParticipant api.
* @param version representation of the required ascendParticipant api version
* @return AscendClientBuilder class
*/
public Builder setVersion(String version) {
this.version = version;
return this;
}
/**
* Sets up a custom AscendAllocationStore. Store needs to implement the
* AscendAllocationStore interface.
* @param allocationStore a custom built allocation store
* @return AscendClientBuilder class
*/
public Builder setAscendAllocationStore(AscendAllocationStore allocationStore) {
this.allocationStore = allocationStore;
return this;
}
/**
* Sets up a custom AscendParticipant.
*
* @deprecated use {@link ai.evolv.AscendClientFactory} init method with AscendConfig
* and AscendParticipant params instead.
*
* @param participant a custom build ascendParticipant
* @return AscendClientBuilder class
*/
@Deprecated
public Builder setAscendParticipant(AscendParticipant participant) {
this.participant = participant;
return this;
}
/**
* Tells the SDK to use either http or https.
* @param scheme either http or https
* @return AscendClientBuilder class
*/
public Builder setHttpScheme(String scheme) {
this.httpScheme = scheme;
return this;
}
/**
* Sets the DefaultAllocationStores size.
* @param size number of entries allowed in the default allocation store
* @return AscendClientBuilder class
*/
public Builder setDefaultAllocationStoreSize(int size) {
this.allocationStoreSize = size;
return this;
}
/**
* Builds an instance of AscendClientImpl.
* @return an AscendClientImpl instance
*/
public AscendConfig build() {
if (allocationStore == null) {
allocationStore = new DefaultAllocationStore(allocationStoreSize);
}
return new AscendConfig(httpScheme, domain, version, environmentId,
allocationStore,
participant,
httpClient);
}
}
}
|
0
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv/AsyncHttpClientImpl.java
|
package ai.evolv;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
@Deprecated
public class AsyncHttpClientImpl
extends ai.evolv.httpclients.AsyncHttpClient implements HttpClient {
/**
*
* @param timeout The milliseconds before the client should timeout and return the default
* value.
*
* @deprecated use {@link ai.evolv.httpclients.AsyncHttpClient} instead.
*/
public AsyncHttpClientImpl(long timeout) {
super(TimeUnit.MILLISECONDS, Math.toIntExact(timeout));
}
/**
* Performs a GET request with the given url using the client from
* org.asynchttpclient.
* @param url a valid url representing a call to the Participant API.
* @return a Completable future instance containing a response from
* the API
*/
public CompletableFuture<String> get(String url) {
return getStringCompletableFuture(url, httpClient);
}
}
|
0
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv/DefaultAllocationStore.java
|
package ai.evolv;
import com.google.gson.JsonArray;
public class DefaultAllocationStore implements AscendAllocationStore {
private LruCache cache;
public DefaultAllocationStore(int size) {
this.cache = new LruCache(size);
}
@Override
public JsonArray get(String uid) {
return cache.getEntry(uid);
}
@Override
public void put(String uid, JsonArray allocations) {
cache.putEntry(uid, allocations);
}
}
|
0
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv/EventEmitter.java
|
package ai.evolv;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.net.URI;
import java.net.URL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class EventEmitter {
private static final Logger LOGGER = LoggerFactory.getLogger(ExecutionQueue.class);
static final String CONFIRM_KEY = "confirmation";
static final String CONTAMINATE_KEY = "contamination";
private final HttpClient httpClient;
private final AscendConfig config;
private final AscendParticipant participant;
private final AscendAllocationStore store;
private final Audience audience = new Audience();
EventEmitter(AscendConfig config, AscendParticipant participant, AscendAllocationStore store) {
this.httpClient = config.getHttpClient();
this.config = config;
this.participant = participant;
this.store = store;
}
void emit(String key) {
String url = getEventUrl(key, 1.0);
makeEventRequest(url);
}
void emit(String key, Double score) {
String url = getEventUrl(key, score);
makeEventRequest(url);
}
void confirm(JsonArray allocations) {
sendAllocationEvents(CONFIRM_KEY, allocations);
}
void contaminate(JsonArray allocations) {
sendAllocationEvents(CONTAMINATE_KEY, allocations);
}
void sendAllocationEvents(String key, JsonArray allocations) {
for (JsonElement a : allocations) {
JsonObject allocation = a.getAsJsonObject();
if (!audience.filter(participant.getUserAttributes(), allocation)
&& Allocations.isTouched(allocation)
&& !Allocations.isConfirmed(allocation)
&& !Allocations.isContaminated(allocation)) {
String experimentId = allocation.get("eid").getAsString();
String candidateId = allocation.get("cid").getAsString();
String url = getEventUrl(key, experimentId, candidateId);
makeEventRequest(url);
if (key.equals(CONFIRM_KEY)) {
Allocations.markConfirmed(allocation);
} else if (key.equals(CONTAMINATE_KEY)) {
Allocations.markContaminated(allocation);
}
continue;
}
LOGGER.debug(String.format("%s event filtered for experiment %s.", key,
allocation.get("eid").getAsString()));
}
store.put(this.participant.getUserId(), allocations);
}
String getEventUrl(String type, Double score) {
try {
String path = String.format("//%s/%s/%s/events", config.getDomain(),
config.getVersion(),
config.getEnvironmentId());
String queryString = String.format("uid=%s&sid=%s&type=%s&score=%s",
participant.getUserId(),
participant.getSessionId(), type, score.toString());
URI uri = new URI(config.getHttpScheme(), null, path, queryString,
null);
URL url = uri.toURL();
return url.toString();
} catch (Exception e) {
LOGGER.error("There was an error while creating the events url.", e);
return null;
}
}
String getEventUrl(String type, String experimentId, String candidateId) {
try {
String path = String.format("//%s/%s/%s/events", config.getDomain(),
config.getVersion(),
config.getEnvironmentId());
String queryString = String.format("uid=%s&sid=%s&eid=%s&cid=%s&type=%s",
participant.getUserId(),
participant.getSessionId(), experimentId, candidateId, type);
URI uri = new URI(config.getHttpScheme(), null, path, queryString,
null);
URL url = uri.toURL();
return url.toString();
} catch (Exception e) {
LOGGER.error("There was an error while creating the events url.", e);
return null;
}
}
private void makeEventRequest(String url) {
if (url != null) {
try {
httpClient.get(url);
} catch (Exception e) {
LOGGER.error(String.format("There was an exception while making" +
" an event request with %s", url), e);
}
} else {
LOGGER.debug("The event url was null, skipping event request.");
}
}
}
|
0
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv/ExecutionQueue.java
|
package ai.evolv;
import ai.evolv.exceptions.AscendKeyError;
import com.google.gson.JsonArray;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class ExecutionQueue {
private static Logger LOGGER = LoggerFactory.getLogger(ExecutionQueue.class);
private final ConcurrentLinkedQueue<Execution> queue;
ExecutionQueue() {
this.queue = new ConcurrentLinkedQueue<>();
}
void enqueue(Execution execution) {
this.queue.add(execution);
}
void executeAllWithValuesFromAllocations(JsonArray allocations,
EventEmitter eventEmitter,
boolean confirmationSandbagged,
boolean contaminationSandbagged) {
while (!queue.isEmpty()) {
Execution execution = queue.remove();
try {
execution.executeWithAllocation(allocations);
} catch (AscendKeyError e) {
LOGGER.debug(String.format("There was an error retrieving" +
" the value of %s from the allocation.", execution.getKey()), e);
execution.executeWithDefault();
} catch (Exception e) {
LOGGER.error("There was an issue while performing one of" +
" the stored actions.", e);
}
}
if (confirmationSandbagged) {
eventEmitter.confirm(allocations);
}
if (contaminationSandbagged) {
eventEmitter.contaminate(allocations);
}
}
void executeAllWithValuesFromDefaults() {
while (!queue.isEmpty()) {
Execution execution = queue.remove();
execution.executeWithDefault();
}
}
}
|
0
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv/HttpClient.java
|
package ai.evolv;
import java.util.concurrent.CompletableFuture;
public interface HttpClient {
/**
* Performs a GET request using the provided url.
* <p>
* This call is asynchronous, the request is sent and a completable future
* is returned. The future is completed when the result of the request returns.
* The timeout of the request is determined in the implementation of the
* HttpClient.
* </p>
* @param url a valid url representing a call to the Participant API.
* @return a response future
*/
CompletableFuture<String> get(String url);
}
|
0
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv/OkHttpClientImpl.java
|
package ai.evolv;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
@Deprecated
public class OkHttpClientImpl extends ai.evolv.httpclients.OkHttpClient implements HttpClient {
/**
* Initializes the OhHttp# client.
*
* @param timeout specify a request timeout for the client.
*
* @deprecated use {@link ai.evolv.httpclients.OkHttpClient} instead.
*/
public OkHttpClientImpl(long timeout) {
super(TimeUnit.MILLISECONDS, Math.toIntExact(timeout));
}
/**
* Performs a GET request with the given url using the client from
* okhttp3.
*
* @param url a valid url representing a call to the Participant API.
* @return a Completable future instance containing a response from
* the API
*/
public CompletableFuture<String> get(String url) {
return getStringCompletableFuture(url, httpClient);
}
}
|
0
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv/httpclients/AsyncHttpClient.java
|
package ai.evolv.httpclients;
import static org.asynchttpclient.Dsl.asyncHttpClient;
import static org.asynchttpclient.Dsl.config;
import ai.evolv.HttpClient;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.asynchttpclient.AsyncHandler;
import org.asynchttpclient.AsyncHttpClientConfig;
import org.asynchttpclient.HttpResponseBodyPart;
import org.asynchttpclient.HttpResponseHeaders;
import org.asynchttpclient.HttpResponseStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AsyncHttpClient implements HttpClient {
private static final Logger LOGGER = LoggerFactory.getLogger(AsyncHttpClient.class);
protected final org.asynchttpclient.AsyncHttpClient httpClient;
/**
* Create an HttpClient based on the org.asynchttpclient library.
*
* <p>Note: Default timeout is 1 second</p>
*/
public AsyncHttpClient() {
this.httpClient = asyncHttpClient(config()
.setRequestTimeout(1000)
.build());
}
/**
* Create an HttpClient based on the org.asynchttpclient library.
*
* @param timeUnit The time unit of the timeout.
* @param timeout The timeout to use.
*/
public AsyncHttpClient(TimeUnit timeUnit, int timeout) {
this.httpClient = asyncHttpClient(config()
.setRequestTimeout(Math.toIntExact(timeUnit.toMillis(timeout)))
.build());
}
/**
* Create an HttpClient based on the org.asynchttpclient library.
*
* @param config An instance of an AsyncHttpClientConfig configuration for use by Ascend
*/
public AsyncHttpClient(AsyncHttpClientConfig config) {
this.httpClient = asyncHttpClient(config);
}
/**
* Create an HttpClient based on the org.asynchttpclient library.
*
* @param client An instance of an AsyncHttpClient for use by Ascend
*/
public AsyncHttpClient(org.asynchttpclient.AsyncHttpClient client) {
this.httpClient = client;
}
/**
* Performs a GET request with the given url using the client from
* org.asynchttpclient.
* @param url a valid url representing a call to the Participant API.
* @return a Completable future instance containing a response from
* the API
*/
public CompletableFuture<String> get(String url) {
return getStringCompletableFuture(url, httpClient);
}
protected static CompletableFuture<String> getStringCompletableFuture(
String url, org.asynchttpclient.AsyncHttpClient httpClient) {
final CompletableFuture<String> responseFuture = new CompletableFuture<>();
StringBuilder chunks = new StringBuilder();
httpClient.prepareGet(url)
.execute(new AsyncHandler<String>() {
@Override
public State onStatusReceived(HttpResponseStatus responseStatus)
throws Exception {
int code = responseStatus.getStatusCode();
if (code >= 200 && code < 300) {
return State.CONTINUE;
}
throw new IOException("The request returned a bad status code.");
}
@Override
public State onHeadersReceived(HttpResponseHeaders headers) {
return State.CONTINUE;
}
@Override
public State onBodyPartReceived(HttpResponseBodyPart bodyPart) {
String chunk = new String(bodyPart.getBodyPartBytes()).trim();
if (chunk.length() != 0) {
chunks.append(chunk);
}
return State.CONTINUE;
}
@Override
public String onCompleted() {
String response = chunks.toString();
responseFuture.complete(response);
return response;
}
@Override
public void onThrowable(Throwable t) {
responseFuture.completeExceptionally(t);
}
});
return responseFuture;
}
}
|
0
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv
|
java-sources/ai/evolv/ascend-sdk/0.7.1/ai/evolv/httpclients/OkHttpClient.java
|
package ai.evolv.httpclients;
import ai.evolv.HttpClient;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.ConnectionPool;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OkHttpClient implements HttpClient {
private static final Logger LOGGER = LoggerFactory.getLogger(OkHttpClient.class);
protected final okhttp3.OkHttpClient httpClient;
/**
* Initializes the OhHttp# httpClient.
* <p>
* Note: Default timeout is 1 second
* </p>
*/
public OkHttpClient() {
this.httpClient = new okhttp3.OkHttpClient.Builder()
.callTimeout(1, TimeUnit.SECONDS)
.connectionPool(new ConnectionPool(3, 1000, TimeUnit.MILLISECONDS))
.build();
}
/**
* Initializes the OhHttp# httpClient.
*
* @param timeUnit Specify the unit of the timeout value.
* @param timeout Specify a request timeout for the httpClient.
*/
public OkHttpClient(TimeUnit timeUnit, long timeout) {
this.httpClient = new okhttp3.OkHttpClient.Builder()
.callTimeout(timeout, timeUnit)
.connectionPool(new ConnectionPool(3, 1000, TimeUnit.MILLISECONDS))
.build();
}
/**
* Initializes the OhHttp# httpClient.
*
* @param httpClient An instance of okhttp3.OkHttpClient for Ascend to use.
*/
public OkHttpClient(okhttp3.OkHttpClient httpClient) {
this.httpClient = httpClient;
}
/**
* Performs a GET request with the given url using the httpClient from
* okhttp3.
* @param url a valid url representing a call to the Participant API.
* @return a Completable future instance containing a response from
* the API
*/
public CompletableFuture<String> get(String url) {
return getStringCompletableFuture(url, httpClient);
}
protected static CompletableFuture<String> getStringCompletableFuture(
String url, okhttp3.OkHttpClient httpClient) {
CompletableFuture<String> responseFuture = new CompletableFuture<>();
final Request request = new Request.Builder()
.url(url)
.build();
httpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
responseFuture.completeExceptionally(e);
}
@Override
public void onResponse(Call call, Response response) {
String body = "";
try (ResponseBody responseBody = response.body()) {
if (responseBody != null) {
body = responseBody.string();
}
if (!response.isSuccessful()) {
throw new IOException(String.format("Unexpected response "
+ "when making GET request: %s using url: %s with body: %s",
response, request.url(), body));
}
responseFuture.complete(body);
} catch (Exception e) {
responseFuture.completeExceptionally(e);
}
}
});
return responseFuture;
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/exceptions/NLApiErrorCode.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.exceptions;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public enum NLApiErrorCode {
DATA_PROCESSING_ERROR(100, "Data Processing Error"),
DATA_EMPTY_ERROR(100, "Data empty Error"),
AUTHENTICATION_ERROR(300, "Authentication Error"),
CONNECTION_ERROR(400, "Connection Error"),
EXECUTION_REQUEST_ERROR(401, "Excecution Request Error"),
AUTHORIZATION_ERROR(401, "Unauthorized Error, please check credetial or authorizion token."),
REQUEST_UNKNOWN_LANGUAGE_ERROR(501, "Unknown Language"),
REQUEST_UNKNOWN_CONTEXT_ERROR(502, "Unknown Context"),
REQUEST_UNKNOWN_TAXONOMY_ERROR(502, "Unknown Taxonomy"),
PARSING_ERROR(600, "Parsing Error");
public static final String BUNDLE_NAME = NLApiErrorCode.class.getName();
private final int errorCode;
private final String errorMessage;
NLApiErrorCode(int errorCode, String errorMessage) {
this.errorCode = errorCode;
this.errorMessage = (errorMessage != null) ? errorMessage : "";
}
public int getErrorCode() {
return errorCode;
}
public String getErrorMessage() {
return errorMessage;
}
public String getBusinessMessage(ResourceBundle bundle) {
try {
return bundle.getString(errorCode + ": " + errorMessage);
}
catch(MissingResourceException e) {
return "NLapi Error (" + errorCode + ": " + errorMessage + ")";
}
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/exceptions/NLApiException.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.exceptions;
import java.util.UUID;
public class NLApiException extends Exception {
private static final long serialVersionUID = 1L;
private final String uuid = UUID.randomUUID().toString();
private final NLApiErrorCode errorCode;
public NLApiException(NLApiErrorCode errorCode) {
super();
this.errorCode = errorCode;
}
public NLApiException(NLApiErrorCode errorCode, String message, Throwable cause) {
super(message, cause);
this.errorCode = errorCode;
}
public NLApiException(NLApiErrorCode errorCode, String message) {
super(message);
this.errorCode = errorCode;
}
public NLApiException(NLApiErrorCode errorCode, Throwable cause) {
super(cause);
this.errorCode = errorCode;
}
@Override
public String getMessage() {
StringBuilder errorMessage = new StringBuilder();
errorMessage.append("error code " + errorCode.getErrorCode() + ": ");
errorMessage.append(errorCode.getErrorMessage());
if(super.getMessage() != null) {
errorMessage.append(" - " + super.getMessage());
}
return errorMessage.toString();
}
public String getExceptionIdentifier() {
return uuid;
}
public NLApiErrorCode getErrorCode() {
return errorCode;
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/security/Authentication.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.security;
import ai.expert.nlapi.exceptions.NLApiException;
import com.auth0.jwt.interfaces.DecodedJWT;
import java.util.Date;
public class Authentication {
private final Authenticator authenticator;
private String JWT;
public Authentication(Authenticator authenticator) {
this.authenticator = authenticator;
}
public boolean isValid() {
return (getJWT() != null && !getJWT().isEmpty() && !isExpired());
}
public boolean isExpired() {
DecodedJWT decodedJWT = com.auth0.jwt.JWT.decode(getJWT());
return decodedJWT.getExpiresAt().before(new Date());
}
public String getJWT() {
return JWT;
}
public void setJWT(String JWT) {
this.JWT = JWT;
}
public String refresh() throws NLApiException {
JWT = authenticator.authenticate();
return JWT;
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/security/Authenticator.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.security;
import ai.expert.nlapi.exceptions.NLApiException;
public interface Authenticator {
String BASE_URL = "https://developer.expert.ai";
String authenticate() throws NLApiException;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/security/BasicAuthenticator.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.security;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.utils.ObjectMapperAdapter;
import ai.expert.nlapi.utils.StringUtils;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Getter
@EqualsAndHashCode
@ToString
public class BasicAuthenticator implements Authenticator {
private static final Logger logger = LoggerFactory.getLogger(BasicAuthenticator.class);
private final Credential credential;
public BasicAuthenticator(Credential credential) {
this.credential = credential;
init();
}
public BasicAuthenticator(CredentialsProvider credentialProvider) {
this.credential = credentialProvider.getCredentials();
init();
}
private void init() {
Unirest.config().setObjectMapper(new ObjectMapperAdapter());
}
@Override
public String authenticate() throws NLApiException {
// check credential
if(credential == null) {
String msg = "Please check credential settings.";
logger.error(msg);
throw new NLApiException(NLApiErrorCode.AUTHENTICATION_ERROR, msg);
}
if (!StringUtils.isBlank(credential.getToken())) {
return credential.getToken();
}
if(credential.getUsername() == null || credential.getUsername().isEmpty()) {
String msg = "Please check settings credential username.";
logger.error(msg);
throw new NLApiException(NLApiErrorCode.AUTHENTICATION_ERROR, msg);
}
if(credential.getPassword() == null || credential.getPassword().isEmpty()) {
String msg = "Please check settings credential password.";
logger.error(msg);
throw new NLApiException(NLApiErrorCode.AUTHENTICATION_ERROR, msg);
}
// make Authentication call to expert.ai
HttpResponse<String> httpResponse = Unirest.post(BASE_URL + "/oauth2/token")
.header("Content-Type", "application/json")
.header("Accept", "*/*")
.body(getCredential().toJSON()).asString();
// check response status
if(httpResponse.getStatus() == 500) {
String msg =
String.format("Authentication call to API %s return error status %d with message %s",
BASE_URL + "/oauth2/token", httpResponse.getStatus(), httpResponse.getBody());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.AUTHORIZATION_ERROR, msg);
}
else if(httpResponse.getStatus() != 200) {
String msg =
String.format("Authentication call to API %s return error status %d",
BASE_URL + "/oauth2/token", httpResponse.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.AUTHORIZATION_ERROR, msg);
}
return httpResponse.getBody();
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/security/Credential.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.security;
import ai.expert.nlapi.utils.StringUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;
import lombok.Value;
@Value
public class Credential {
@JsonProperty
String username;
@JsonProperty
String password;
String token;
public boolean isValid() {
if (!StringUtils.isBlank(token)) {
return true;
}
if(StringUtils.isBlank(username)) {return false;}
return !StringUtils.isBlank(password);
}
@SneakyThrows
public String toJSON() {
return new ObjectMapper().writeValueAsString(this);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/security/CredentialsProvider.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.security;
abstract class CredentialsProvider {
protected CredentialsProvider nextCredentialsProvider;
// set next in chain of responsibility
protected CredentialsProvider setNextCredentialsProvider(CredentialsProvider nextCredentialsProvider) {
this.nextCredentialsProvider = nextCredentialsProvider;
return this.nextCredentialsProvider;
}
// solve credential in chain of responsibility
public Credential solveCredentials() {
Credential credential = getCredentials();
if(credential != null) {
// credetials solved
return credential;
}
else if(nextCredentialsProvider != null) {
// ask next CredentialsProvide to solve credetials
return nextCredentialsProvider.solveCredentials();
}
// no possibility to solve credetials
return null;
}
// CredentialsProvider checks if credential are set
// null if not set
abstract public Credential getCredentials();
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/security/DefaultCredentialsProvider.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.security;
public class DefaultCredentialsProvider extends CredentialsProvider {
private CredentialsProvider providerChain;
public DefaultCredentialsProvider() {
providerChain = null;
init();
}
private void init() {
// set the chain of CredentialsProvider
providerChain = new EnvironmentVariablesCredentialsProvider();
providerChain.setNextCredentialsProvider(new SystemPropertyCredentialsProvider());
}
public Credential getCredentials() {
// get credentials using the chain of CredentialsProvider
return providerChain.solveCredentials();
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/security/EnvironmentVariablesCredentialsProvider.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.security;
import ai.expert.nlapi.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EnvironmentVariablesCredentialsProvider extends CredentialsProvider {
private static final Logger logger = LoggerFactory.getLogger(EnvironmentVariablesCredentialsProvider.class);
public EnvironmentVariablesCredentialsProvider() {
}
public Credential getCredentials() {
logger.debug("Getting Credentials from Environment Variables...");
String username = StringUtils.trim(System.getenv(SecurityUtils.USER_ACCESS_KEY_ENV));
String password = StringUtils.trim(System.getenv(SecurityUtils.PASSWORD_ACCESS_KEY_ENV));
String token = StringUtils.trim(System.getenv(SecurityUtils.TOKEN_ACCESS_KEY_ENV));
if (token==null || token.isEmpty()) {
// check the variables, if not valid return null
if(username == null || username.isEmpty()) {
return null;
}
if(password == null || password.isEmpty()) {
return null;
}
logger.info("Found Credentials from Environment Variables.");
} else {
logger.info("Found Token from Environment Variables.");
}
return new Credential(username, password, token);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/security/SecurityUtils.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.security;
public class SecurityUtils {
// keys used for SystemPropertyCredentialsProvider
public static final String USER_ACCESS_KEY_PROP = "eai.username";
public static final String PASSWORD_ACCESS_KEY_PROP = "eai.password";
public static final String TOKEN_ACCESS_KEY_PROP = "eai.token";
// keys used for EnvironmentVariablesCredentialsProvider
public static final String USER_ACCESS_KEY_ENV = "EAI_USERNAME";
public static final String PASSWORD_ACCESS_KEY_ENV = "EAI_PASSWORD";
public static final String TOKEN_ACCESS_KEY_ENV = "EAI_TOKEN";
public static String bearerOf(String JWT) {
return String.format("Bearer %s", JWT);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/security/SystemPropertyCredentialsProvider.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.security;
import ai.expert.nlapi.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SystemPropertyCredentialsProvider extends CredentialsProvider {
private static final Logger logger = LoggerFactory.getLogger(SystemPropertyCredentialsProvider.class);
public SystemPropertyCredentialsProvider() {
}
public Credential getCredentials() {
logger.debug("Getting Credentials from System Property...");
String username = StringUtils.trim(System.getProperty(SecurityUtils.USER_ACCESS_KEY_PROP));
String password = StringUtils.trim(System.getProperty(SecurityUtils.PASSWORD_ACCESS_KEY_PROP));
String token = StringUtils.trim(System.getProperty(SecurityUtils.TOKEN_ACCESS_KEY_PROP));
if (token==null || token.isEmpty()) {
// check the variables, if not valid return null
if(username == null || username.isEmpty()) {
return null;
}
if(password == null || password.isEmpty()) {
return null;
}
logger.info("Found Credentials from System Property.");
} else {
logger.info("Found Token from System Property.");
}
return new Credential(username, password, token);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/utils/APIUtils.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.utils;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.security.SecurityUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class APIUtils {
private static final Logger logger = LoggerFactory.getLogger(APIUtils.class);
public static <T> T fromJSON(String json, Class<T> valueType) throws NLApiException {
T response;
try {
ObjectMapper om = new ObjectMapper();
// Trying to deserialize value into an enum, don't fail on unknown value, use null instead
om.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
// Just ignore unknown fields, don't stop parsing
//om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
response = om.readValue(json, valueType);
}
catch(JsonMappingException e) {
String msg = String.format("Please report this issue. Error while parsing json response into class [%s]: %s",
valueType.toString(),
json);
logger.error(msg,e);
throw new NLApiException(NLApiErrorCode.PARSING_ERROR, msg);
}
catch(JsonProcessingException e) {
String msg = String.format("Please report this issue. Error while processing json into class [%s]: %s",
valueType.toString(),
json);
logger.error(msg,e);
throw new NLApiException(NLApiErrorCode.PARSING_ERROR, msg);
}
return response;
}
public static String getBearerToken(Authentication authentication) throws NLApiException {
return SecurityUtils.bearerOf(authentication.isValid() ? authentication.getJWT() : authentication.refresh());
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/utils/ObjectMapperAdapter.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.SerializationFeature;
import kong.unirest.ObjectMapper;
import java.io.IOException;
public class ObjectMapperAdapter implements ObjectMapper {
private final com.fasterxml.jackson.databind.ObjectMapper om;
public ObjectMapperAdapter() {
om = new com.fasterxml.jackson.databind.ObjectMapper();
om.enable(SerializationFeature.WRAP_ROOT_VALUE);
}
@Override
public <T> T readValue(String value, Class<T> valueType) {
try {
return om.readValue(value, valueType);
}
catch(IOException e) {
throw new RuntimeException(e);
}
}
@Override
public String writeValue(Object value) {
try {
return om.writeValueAsString(value);
}
catch(JsonProcessingException e) {
throw new RuntimeException(e);
}
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/utils/StringUtils.java
|
package ai.expert.nlapi.utils;
public class StringUtils {
/**
* The empty String
*/
private static final String EMPTY = "";
/**
* should not be used
*/
public StringUtils() {
}
/**
* Checks if a String is empty ("") or null.
*
* @param s the String to check, may be null
* @return true if the String is empty or null
*/
public static boolean isEmpty(final String s) {
return s == null || s.length() == 0;
}
/**
* Checks if a String is empty (""), null or whitespace only.
*
* @param s the String to check, may be null
* @return true if the String is null, empty or whitespace only
*/
public static boolean isBlank(final String s) {
if(s == null || s.length() == 0) {
return true;
}
for(int i = 0; i < s.length(); i++) {
if(!Character.isWhitespace(s.charAt(i))) {
return false;
}
}
return true;
}
/**
* Checks if a String is not empty (""), not null and not whitespace only.
*
* @param s the String to check, may be null
* @return true if the CharSequence is not empty and not null and not whitespace only
*/
public static boolean isNotBlank(final String s) {
return !isBlank(s);
}
/**
* Trim String, if null returns null
*
* @param str the String to be trimmed
* @return the trimmed string
*/
public static String trim(final String str) {
return str == null ? null : str.trim();
}
/**
* Trim String, if null or empty returns null
*
* @param str the String to be trimmed
* @return the trimmed String
*/
public static String trimToNull(final String str) {
String ts = trim(str);
return isEmpty(ts) ? null : ts;
}
/**
* Trim String, if null or empty returns empty
*
* @param str the String to be trimmed
* @return the trimmed String
*/
public static String trimToEmpty(final String str) {
return str == null ? EMPTY : str.trim();
}
/**
* Compares two Strings
*
* @param str1 the first String
* @param str2 the second String
* @return {@code true} if the Strings are equal, case-sensitive
*/
public static boolean equals(final String str1, final String str2) {
if(str1 == null || str2 == null) {
return false;
}
if(str1.length() != str2.length()) {
return false;
}
return str1.equals(str2);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/API.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2;
public class API {
public static final String AUTHORITY = "https://nlapi.expert.ai";
public static final String EDGE_AUTHORITY = "https://edgeapi.expert.ai";
public static final String DEFAULT_EDGE_HOST = "http://127.0.0.1:6699";
public enum Versions {
V1("v1"),
V2("v2");
private final String value;
Versions(String value) {
this.value = value;
}
public String value() {
return value;
}
@Override
public String toString() {
return value();
}
}
public enum Contexts {
STANDARD("standard");
private final String value;
Contexts(String value) {
this.value = value;
}
public String value() {
return value;
}
@Override
public String toString() {
return value();
}
}
public enum Taxonomies {
IPTC("iptc"),
GEOTAX("geotax");
private final String value;
Taxonomies(String value) {
this.value = value;
}
public String value() {
return value;
}
@Override
public String toString() {
return value();
}
}
public enum Languages {
de("de", "German"),
en("en", "English"),
es("es", "Spanish"),
fr("fr", "French"),
it("it", "Italian");
private final String code;
private final String name;
Languages(String code, String name) {
this.code = code;
this.name = name;
}
public String code() {
return code;
}
public String getName() {
return name;
}
@Override
public String toString() {
return getName();
}
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/cloud/Analyzer.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.cloud;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.utils.APIUtils;
import ai.expert.nlapi.utils.ObjectMapperAdapter;
import ai.expert.nlapi.v2.API;
import ai.expert.nlapi.v2.message.AnalysisRequest;
import ai.expert.nlapi.v2.message.AnalyzeResponse;
import ai.expert.nlapi.v2.model.Document;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Analyzer {
private static final Logger logger = LoggerFactory.getLogger(Analyzer.class);
private final Authentication authentication;
private final String URL;
public Analyzer(AnalyzerConfig config) {
authentication = config.getAuthentication();
URL = String.format("%s/%s/analyze/%s/%s",
API.AUTHORITY, config.getVersion(), config.getContext().toLowerCase(), config.getLanguage().code());
Unirest.config()
.addDefaultHeader("Content-Type", "application/json")
.addDefaultHeader("Accept", "application/json")
.setObjectMapper(new ObjectMapperAdapter());
}
public AnalyzeResponse analyze(String text, String analysisType) throws NLApiException {
return getResponseDocument(text, analysisType);
}
public AnalyzeResponse analyze(String text) throws NLApiException {
return getResponseDocument(text, null);
}
public AnalyzeResponse disambiguation(String text) throws NLApiException {
return getResponseDocument(text, "disambiguation");
}
public AnalyzeResponse relevants(String text) throws NLApiException {
return getResponseDocument(text, "relevants");
}
public AnalyzeResponse entities(String text) throws NLApiException {
return getResponseDocument(text, "entities");
}
public AnalyzeResponse relations(String text) throws NLApiException {
return getResponseDocument(text, "relations");
}
public AnalyzeResponse sentiment(String text) throws NLApiException {
return getResponseDocument(text, "sentiment");
}
private AnalyzeResponse getResponseDocument(String text, String analysisType) throws NLApiException {
// get json reply from expert.ai API
String json = getResponseDocumentString(text, analysisType);
// parsing and checking response
AnalyzeResponse response = APIUtils.fromJSON(json, AnalyzeResponse.class);
if(response.isSuccess()) {
return response;
}
String msg = String.format("Analyze call to API %s return an error json: %s", URL, json);
logger.error(msg);
throw new NLApiException(NLApiErrorCode.EXECUTION_REQUEST_ERROR, msg);
}
public String getResponseDocumentString(String text, String analysisType) throws NLApiException {
String URLpath = URL;
// if analysisType is defined and different from "full" enable specific analysis type, e.g. "entities"
if(analysisType != null && !analysisType.isEmpty() && !analysisType.equalsIgnoreCase("full")) {
URLpath = URL + "/" + analysisType.toLowerCase();
}
logger.debug("Sending text to analyze API: " + URLpath);
HttpResponse<String> response = Unirest.post(URLpath)
.header("Authorization", APIUtils.getBearerToken(authentication))
.body(new AnalysisRequest(Document.of(text)).toJSON())
.asString();
/*
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'413':
description: Request Entity Too Large
'500':
description: Internal Server Error
*/
if(response.getStatus() != 200) {
String msg = String.format("Analyze call to API %s return error status %d", URLpath, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
String type = (analysisType != null && !analysisType.isEmpty()) ? analysisType : "full";
logger.info(String.format("Analyze %s call successful", type));
return response.getBody();
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/cloud/AnalyzerConfig.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.cloud;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.v2.API;
import lombok.Builder;
import lombok.Value;
@Value
@Builder(setterPrefix = "with")
public class AnalyzerConfig {
API.Versions version;
String context;
API.Languages language;
Authentication authentication;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/cloud/Categorizer.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.cloud;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.utils.APIUtils;
import ai.expert.nlapi.utils.ObjectMapperAdapter;
import ai.expert.nlapi.v2.API;
import ai.expert.nlapi.v2.message.AnalysisRequest;
import ai.expert.nlapi.v2.message.CategorizeResponse;
import ai.expert.nlapi.v2.model.Document;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Categorizer {
private static final Logger logger = LoggerFactory.getLogger(Categorizer.class);
private final Authentication authentication;
private final String URL;
public Categorizer(CategorizerConfig config) {
authentication = config.getAuthentication();
URL = String.format("%s/%s/categorize/%s/%s",
API.AUTHORITY, config.getVersion(), config.getTaxonomy().toLowerCase(), config.getLanguage().code());
Unirest.config()
.addDefaultHeader("Content-Type", "application/json")
.addDefaultHeader("Accept", "application/json")
.setObjectMapper(new ObjectMapperAdapter());
}
public CategorizeResponse categorize(String text) throws NLApiException {
// get json reply from expert.ai API
String json = categorizeAsString(text);
// parsing and checking response
CategorizeResponse response = APIUtils.fromJSON(json, CategorizeResponse.class);
if(response.isSuccess()) {
return response;
}
String msg = String.format("Categorize call to API %s return an error json: %s", URL, json);
logger.error(msg);
throw new NLApiException(NLApiErrorCode.EXECUTION_REQUEST_ERROR, msg);
}
public String categorizeAsString(String text) throws NLApiException {
logger.debug("Sending text to categorize API: " + URL);
HttpResponse<String> response = Unirest.post(URL)
.header("Authorization", APIUtils.getBearerToken(authentication))
.body(new AnalysisRequest(Document.of(text)).toJSON())
.asString();
if(response.getStatus() != 200) {
String msg = String.format("Categorize call to API %s return error status %d", URL, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
logger.info("Categorize call successful");
return response.getBody();
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/cloud/CategorizerConfig.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.cloud;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.v2.API;
import lombok.Builder;
import lombok.Value;
@Value
@Builder(setterPrefix = "with")
public class CategorizerConfig {
API.Versions version;
String taxonomy;
API.Languages language;
Authentication authentication;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/cloud/Detector.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.cloud;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.utils.APIUtils;
import ai.expert.nlapi.utils.ObjectMapperAdapter;
import ai.expert.nlapi.v2.API;
import ai.expert.nlapi.v2.message.AnalysisRequest;
import ai.expert.nlapi.v2.message.DetectResponse;
import ai.expert.nlapi.v2.model.Document;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Detector {
private static final Logger logger = LoggerFactory.getLogger(Detector.class);
private final Authentication authentication;
private final String URL;
public Detector(DetectorConfig config) {
authentication = config.getAuthentication();
URL = String.format("%s/%s/detect/%s/%s",
API.AUTHORITY, config.getVersion(), config.getDetector().toLowerCase(), config.getLanguage().code());
Unirest.config()
.addDefaultHeader("Content-Type", "application/json")
.addDefaultHeader("Accept", "application/json")
.setObjectMapper(new ObjectMapperAdapter());
}
public DetectResponse detect(String text) throws NLApiException {
// get json reply from expert.ai API
String json = detectionAsString(text);
// parsing and checking response
DetectResponse response = APIUtils.fromJSON(json, DetectResponse.class);
if(response.isSuccess()) {
return response;
}
String msg = String.format("Detection call to API %s return an error json: %s", URL, json);
logger.error(msg);
throw new NLApiException(NLApiErrorCode.EXECUTION_REQUEST_ERROR, msg);
}
public String detectionAsString(String text) throws NLApiException {
logger.debug("Sending text to detect API: " + URL);
HttpResponse<String> response = Unirest.post(URL)
.header("Authorization", APIUtils.getBearerToken(authentication))
.body(new AnalysisRequest(Document.of(text)).toJSON())
.asString();
if(response.getStatus() != 200) {
String msg = String.format("Detection call to API %s return error status %d", URL, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
logger.info("Detection call successful");
return response.getBody();
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/cloud/DetectorConfig.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.cloud;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.v2.API;
import lombok.Builder;
import lombok.Value;
@Value
@Builder(setterPrefix = "with")
public class DetectorConfig {
API.Versions version;
String detector;
API.Languages language;
Authentication authentication;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/cloud/InfoAPI.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.cloud;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.utils.APIUtils;
import ai.expert.nlapi.utils.ObjectMapperAdapter;
import ai.expert.nlapi.v2.API;
import ai.expert.nlapi.v2.message.ContextsResponse;
import ai.expert.nlapi.v2.message.DetectorsResponse;
import ai.expert.nlapi.v2.message.TaxonomiesResponse;
import ai.expert.nlapi.v2.message.TaxonomyResponse;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Gio
*/
public class InfoAPI {
private static final Logger logger = LoggerFactory.getLogger(InfoAPI.class);
private final Authentication authentication;
private final String URL;
public InfoAPI(InfoAPIConfig config) {
authentication = config.getAuthentication();
URL = String.format("%s/%s", API.AUTHORITY, config.getVersion());
Unirest.config()
.addDefaultHeader("Content-Type", "application/json")
.addDefaultHeader("Accept", "application/json")
.setObjectMapper(new ObjectMapperAdapter());
}
/**
* Returns information about available contexts
*
* @return Contexts
*/
public ContextsResponse getContexts() throws NLApiException {
String URLGet = URL + "/contexts";
logger.debug("Calling GET contexts: " + URLGet);
HttpResponse<String> response = Unirest.get(URLGet)
.header("Authorization", APIUtils.getBearerToken(authentication))
.asString();
if(response.getStatus() != 200) {
String msg = String.format("GET contexts call to API %s return error status %d", URLGet, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
logger.info("GET contexts call successful");
return APIUtils.fromJSON(response.getBody(), ContextsResponse.class);
}
public DetectorsResponse getDetectors() throws NLApiException {
String URLGet = URL + "/detectors";
logger.debug("Calling GET contexts: " + URLGet);
HttpResponse<String> response = Unirest.get(URLGet)
.header("Authorization", APIUtils.getBearerToken(authentication))
.asString();
if(response.getStatus() != 200) {
String msg = String.format("GET contexts call to API %s return error status %d", URLGet, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
logger.info("GET contexts call successful");
return APIUtils.fromJSON(response.getBody(), DetectorsResponse.class);
}
/**
* Returns information about available taxonomies
*
* @return Taxonomies
*/
public TaxonomiesResponse getTaxonomies() throws NLApiException {
String URLGet = URL + "/taxonomies";
logger.debug("Calling GET taxonomies: " + URLGet);
HttpResponse<String> response = Unirest.get(URLGet)
.header("Authorization", APIUtils.getBearerToken(authentication))
.asString();
if(response.getStatus() != 200) {
String msg = String.format("GET taxonomies call to API %s return error status %d", URLGet, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
logger.info("GET taxonomies call successful");
return APIUtils.fromJSON(response.getBody(), TaxonomiesResponse.class);
}
/**
* Returns information about available taxonomy for specific language
*
* @return Taxonomy
*/
public TaxonomyResponse getTaxonomy(String taxonomy, API.Languages lang) throws NLApiException {
String URLGet = String.format("%s/taxonomies/%s/%s", URL, taxonomy.toLowerCase(), lang.code());
logger.debug("Calling GET taxonomy: " + URLGet);
HttpResponse<String> response = Unirest.get(URLGet)
.header("Authorization", APIUtils.getBearerToken(authentication))
.asString();
if(response.getStatus() != 200) {
String msg = String.format("GET taxonomy call to API %s return error status %d", URLGet, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
logger.info("GET taxonomy call successful");
return APIUtils.fromJSON(response.getBody(), TaxonomyResponse.class);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/cloud/InfoAPIConfig.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.cloud;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.v2.API;
import lombok.Builder;
import lombok.Value;
@Value
@Builder(setterPrefix = "with")
public class InfoAPIConfig {
API.Versions version;
Authentication authentication;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/edge/Analyzer.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.edge;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.utils.APIUtils;
import ai.expert.nlapi.utils.ObjectMapperAdapter;
import ai.expert.nlapi.v2.API;
import ai.expert.nlapi.v2.message.AnalysisRequestWithOptions;
import ai.expert.nlapi.v2.message.AnalyzeResponse;
import ai.expert.nlapi.v2.model.Document;
import ai.expert.nlapi.v2.model.Options;
import ai.expert.nlapi.v2.message.EdgeKeyResponse;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import org.apache.commons.codec.digest.MessageDigestAlgorithms;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.security.MessageDigest;
import java.util.Map;
public class Analyzer {
private static final Logger logger = LoggerFactory.getLogger(Analyzer.class);
private final Authentication authentication;
private final String resource;
private final String EKEY_URL;
private final String EDGE_URL;
public Analyzer(AnalyzerConfig config) {
authentication = config.getAuthentication();
resource = config.getResource();
EKEY_URL = String.format("%s/edge/key", API.EDGE_AUTHORITY);
EDGE_URL = String.format("%s/api/analyze", config.getHost());
Unirest.config()
.addDefaultHeader("Content-Type", "application/json")
.addDefaultHeader("Accept", "application/json")
.setObjectMapper(new ObjectMapperAdapter());
}
public AnalyzeResponse analyze(String text, List<String> analysis, List<String> features) throws NLApiException {
return getResponseDocument(text, analysis, features,null);
}
public AnalyzeResponse analyze(String text, List<String> analysis, List<String> features, Map<String,Object> extra) throws NLApiException {
return getResponseDocument(text, analysis, features,extra);
}
public AnalyzeResponse analyze(String text) throws NLApiException {
ArrayList<String> analysis = new ArrayList<>();
analysis.add("disambiguation");
analysis.add("relevants");
analysis.add("entities");
analysis.add("sentiment");
analysis.add("relations");
ArrayList<String> features = new ArrayList<>();
features.add("syncpos");
features.add("knowledge");
features.add("dependency");
return getResponseDocument(text, analysis, features,null);
}
public AnalyzeResponse disambiguation(String text) throws NLApiException {
ArrayList<String> analysis = new ArrayList<>();
analysis.add("disambiguation");
ArrayList<String> features = new ArrayList<>();
features.add("syncpos");
features.add("knowledge");
features.add("dependency");
return getResponseDocument(text, analysis, features,null);
}
public AnalyzeResponse relevants(String text) throws NLApiException {
ArrayList<String> analysis = new ArrayList<>();
analysis.add("relevants");
ArrayList<String> features = new ArrayList<>();
features.add("syncpos");
features.add("knowledge");
return getResponseDocument(text, analysis, features,null);
}
public AnalyzeResponse entities(String text) throws NLApiException {
ArrayList<String> analysis = new ArrayList<>();
analysis.add("entities");
ArrayList<String> features = new ArrayList<>();
features.add("syncpos");
features.add("knowledge");
return getResponseDocument(text, analysis, features,null);
}
public AnalyzeResponse relations(String text) throws NLApiException {
ArrayList<String> analysis = new ArrayList<>();
analysis.add("relations");
ArrayList<String> features = new ArrayList<>();
features.add("syncpos");
features.add("knowledge");
features.add("dependency");
return getResponseDocument(text, analysis, features,null);
}
public AnalyzeResponse sentiment(String text) throws NLApiException {
ArrayList<String> analysis = new ArrayList<>();
analysis.add("sentiment");
ArrayList<String> features = new ArrayList<>();
features.add("syncpos");
features.add("knowledge");
return getResponseDocument(text, analysis, features,null);
}
public AnalyzeResponse classification(String text) throws NLApiException {
ArrayList<String> analysis = new ArrayList<>();
analysis.add("categories");
ArrayList<String> features = new ArrayList<>();
features.add("syncpos");
return getResponseDocument(text, analysis, features,null);
}
public AnalyzeResponse extraction(String text) throws NLApiException {
ArrayList<String> analysis = new ArrayList<>();
analysis.add("extractions");
ArrayList<String> features = new ArrayList<>();
features.add("syncpos");
return getResponseDocument(text, analysis, features,null);
}
private AnalyzeResponse getResponseDocument(String text, List<String> analysis, List<String> features,
Map<String,Object> extra) throws NLApiException {
// get json reply from expert.ai API
String json = getResponseDocumentString(text, analysis, features,extra);
// parsing and checking response
AnalyzeResponse response = APIUtils.fromJSON(json, AnalyzeResponse.class);
if(response.isSuccess()) {
return response;
}
String msg = String.format("Edge Analyze call return an error json: %s", json);
logger.error(msg);
throw new NLApiException(NLApiErrorCode.EXECUTION_REQUEST_ERROR, msg);
}
private String getMD5(String text) {
String res = null;
try {
MessageDigest md = MessageDigest.getInstance(MessageDigestAlgorithms.MD5);
byte[] array = md.digest(text.getBytes(StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < array.length; ++i) {
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
}
res = sb.toString();
} catch(NoSuchAlgorithmException ex) {
logger.error("getMD5 exception: " + ex.getMessage());
}
return res;
}
private String getExecutionKey(String md5) throws NLApiException {
String URLpath = EKEY_URL + "/" + md5;
logger.debug("Requesting execution-key: " + URLpath);
HttpResponse<String> response = Unirest.get(URLpath).header("Authorization", APIUtils.getBearerToken(authentication)).asString();
if (response.getStatus()!=200) {
String msg = String.format("Edge Execution key call to API %s return error status %d", URLpath, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
EdgeKeyResponse keyResponse = APIUtils.fromJSON(response.getBody(), EdgeKeyResponse.class);
return keyResponse.getKey();
}
private String getResponseDocumentString(String text,
List<String> analysis,
List<String> features,
Map<String,Object> extra) throws NLApiException {
String ekey = "";
if (authentication!=null) {
String md5 = getMD5(text);
if(md5 == null) {
String msg = "Error generating text md5 hash";
throw new NLApiException(NLApiErrorCode.DATA_PROCESSING_ERROR, msg);
}
ekey = getExecutionKey(md5);
}
String URLpath = EDGE_URL;
logger.debug("Sending text to edge analyze API: " + URLpath);
HttpResponse<String> response = Unirest.post(URLpath)
.header("execution-key", ekey)
.body(new AnalysisRequestWithOptions(Document.of(text), Options.of(analysis, features,extra), resource).toJSON())
.asString();
/*
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'413':
description: Request Entity Too Large
'500':
description: Internal Server Error
*/
if(response.getStatus() != 200) {
String msg = String.format("Edge Analyze call to API %s return error status %d", URLpath, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
logger.info("Edge Analyze call successful");
return response.getBody();
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/edge/AnalyzerConfig.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.edge;
import ai.expert.nlapi.security.Authentication;
import ai.expert.nlapi.v2.API;
import lombok.Builder;
import lombok.Value;
@Value
@Builder(setterPrefix = "with")
public class AnalyzerConfig {
API.Versions version;
String host;
String resource;
Authentication authentication;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/edge/Info.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.edge;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.utils.APIUtils;
import ai.expert.nlapi.utils.ObjectMapperAdapter;
import ai.expert.nlapi.v2.message.*;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Info {
private static final Logger logger = LoggerFactory.getLogger(Info.class);
private final String RESOURCES_URL;
private final String STATISTICS_URL;
private final String HEALTH_URL;
public Info(InfoConfig config) {
String host = config.getHost();
RESOURCES_URL = String.format("%s/essex/packages", host);
STATISTICS_URL = String.format("%s/essex/statistics", host);
HEALTH_URL = String.format("%s/health", host);
Unirest.config()
.addDefaultHeader("Content-Type", "application/json")
.addDefaultHeader("Accept", "application/json")
.setObjectMapper(new ObjectMapperAdapter());
}
public ResourcesInfoResponse resources() throws NLApiException {
return getResourcesInfoResponse();
}
public StatisticsInfoResponse statistics() throws NLApiException {
return getStatisticsInfoResponse();
}
public void health() throws NLApiException {
HttpResponse<String> response = Unirest.get(HEALTH_URL).asString();
if (response.getStatus() != 200) {
String msg = String.format("GET call to API %s return error status %d", HEALTH_URL, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
}
private ResourcesInfoResponse getResourcesInfoResponse() throws NLApiException {
// get json reply from expert.ai API
String json = getInfoResponseString(RESOURCES_URL);
// parsing and checking response
ResourcesInfoResponse response = APIUtils.fromJSON(json, ResourcesInfoResponse.class);
if (response.isSuccess()) {
return response;
}
String msg = String.format("Edge Resources Info call return an error json: %s", json);
logger.error(msg);
throw new NLApiException(NLApiErrorCode.EXECUTION_REQUEST_ERROR, msg);
}
private StatisticsInfoResponse getStatisticsInfoResponse() throws NLApiException {
// get json reply from expert.ai API
String json = getInfoResponseString(STATISTICS_URL);
// parsing and checking response
StatisticsInfoResponse response = APIUtils.fromJSON(json, StatisticsInfoResponse.class);
if (response.isSuccess()) {
return response;
}
String msg = String.format("Edge Statistics Info call return an error json: %s", json);
logger.error(msg);
throw new NLApiException(NLApiErrorCode.EXECUTION_REQUEST_ERROR, msg);
}
private String getInfoResponseString(String url) throws NLApiException {
logger.debug("Sending request to Edge Info API: " + url);
HttpResponse<String> response = Unirest.post(url)
.body("")
.asString();
/*
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'413':
description: Request Entity Too Large
'500':
description: Internal Server Error
*/
if (response.getStatus() != 200) {
String msg = String.format("Edge Info call to API %s return error status %d", url, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
logger.info("Edge Info call successful");
return response.getBody();
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/edge/InfoConfig.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.edge;
import ai.expert.nlapi.v2.API;
import lombok.Builder;
import lombok.Value;
@Value
@Builder(setterPrefix = "with")
public class InfoConfig {
API.Versions version;
String host;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/edge/Model.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.edge;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.utils.APIUtils;
import ai.expert.nlapi.utils.ObjectMapperAdapter;
import ai.expert.nlapi.v2.message.*;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Model {
private static final Logger logger = LoggerFactory.getLogger(Model.class);
private final String resource;
private final String EDGE_URL;
public Model(ModelConfig config) {
resource = config.getResource();
EDGE_URL = String.format("%s/api/model", config.getHost());
Unirest.config()
.addDefaultHeader("Content-Type", "application/json")
.addDefaultHeader("Accept", "application/json")
.setObjectMapper(new ObjectMapperAdapter());
}
public TaxonomyModelResponse taxonomy() throws NLApiException {
return getTaxonomyModelResponse();
}
public TemplatesModelResponse templates() throws NLApiException {
return getTemplatesModelResponse();
}
private TaxonomyModelResponse getTaxonomyModelResponse() throws NLApiException {
// get json reply from expert.ai API
String json = getModelResponseString("taxonomy");
// parsing and checking response
TaxonomyModelResponse response = APIUtils.fromJSON(json, TaxonomyModelResponse.class);
if(response.isSuccess()) {
return response;
}
String msg = String.format("Edge taxonomy model call return an error json: %s", json);
logger.error(msg);
throw new NLApiException(NLApiErrorCode.EXECUTION_REQUEST_ERROR, msg);
}
private TemplatesModelResponse getTemplatesModelResponse() throws NLApiException {
// get json reply from expert.ai API
String json = getModelResponseString("templates");
// parsing and checking response
TemplatesModelResponse response = APIUtils.fromJSON(json, TemplatesModelResponse.class);
if(response.isSuccess()) {
return response;
}
String msg = String.format("Edge templates model call return an error json: %s", json);
logger.error(msg);
throw new NLApiException(NLApiErrorCode.EXECUTION_REQUEST_ERROR, msg);
}
private String getModelResponseString(String model) throws NLApiException {
String URLpath = EDGE_URL;
ModelRequest mr = new ModelRequest();
mr.setInfo(model);
mr.setResource(resource);
logger.debug("Sending request to Edge Model API: " + URLpath);
HttpResponse<String> response = Unirest.post(URLpath)
.body(mr.toJSON())
.asString();
/*
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'413':
description: Request Entity Too Large
'500':
description: Internal Server Error
*/
if(response.getStatus() != 200) {
String msg = String.format("Edge Model call to API %s return error status %d", URLpath, response.getStatus());
logger.error(msg);
throw new NLApiException(NLApiErrorCode.CONNECTION_ERROR, msg);
}
logger.info("Edge Model call successful");
return response.getBody();
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/edge/ModelConfig.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.edge;
import ai.expert.nlapi.v2.API;
import lombok.Builder;
import lombok.Value;
@Value
@Builder(setterPrefix = "with")
public class ModelConfig {
API.Versions version;
String host;
String resource;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/AnalysisRequest.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.v2.model.Document;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AnalysisRequest {
Document document;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/AnalysisRequestWithOptions.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.v2.model.Document;
import ai.expert.nlapi.v2.model.Options;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AnalysisRequestWithOptions {
Document document;
Options options;
String resource;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
om.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return om.writeValueAsString(this);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/AnalyzeResponse.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.v2.model.AnalyzeDocument;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AnalyzeResponse {
@JsonProperty("success")
private boolean success;
@JsonProperty("errors")
private List<ServiceError> errors;
@JsonProperty("data")
private AnalyzeDocument data;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/CategorizeResponse.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.v2.model.CategorizeDocument;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CategorizeResponse {
@JsonProperty("success")
private boolean success;
@JsonProperty("errors")
private List<ServiceError> errors;
@JsonProperty("data")
private CategorizeDocument data;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/ContextsResponse.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.v2.model.ContextInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ContextsResponse {
private List<ContextInfo> contexts;
public ContextInfo getContextByName(String name) throws NLApiException {
return contexts.stream()
.filter(context -> context.getName().equals(name))
.findAny()
.orElseThrow(() -> new NLApiException(NLApiErrorCode.REQUEST_UNKNOWN_CONTEXT_ERROR));
}
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/DetectResponse.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.v2.model.CategorizeDocument;
import ai.expert.nlapi.v2.model.DetectDocument;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DetectResponse {
@JsonProperty(value="success",required = true)
private boolean success;
@JsonProperty(value = "errors",required = false)
private List<ServiceError> errors;
@JsonProperty(value = "data",required = true)
private DetectDocument data;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/DetectorsResponse.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.v2.model.ContextInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DetectorsResponse {
private List<ContextInfo> detectors;
public ContextInfo getDetectorByName(String name) throws NLApiException {
return detectors.stream()
.filter(context -> context.getName().equals(name))
.findAny()
.orElseThrow(() -> new NLApiException(NLApiErrorCode.REQUEST_UNKNOWN_CONTEXT_ERROR));
}
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/EdgeKeyResponse.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.message;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EdgeKeyResponse {
@JsonProperty("key")
private String key;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/InstanceError.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class InstanceError {
private int code;
private String text;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/ModelRequest.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.message;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ModelRequest {
String info;
String resource;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/ResourcesInfoResponse.java
|
/*
* Copyright (c) 2021 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.v2.model.ResourceInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResourcesInfoResponse {
@JsonProperty("result")
private String result;
@JsonProperty("server")
private String server;
@JsonProperty("time")
private double time;
@JsonProperty("itime")
private double itime;
@JsonProperty("error")
private InstanceError error;
@JsonProperty("data")
private List<ResourceInfo> data;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
public boolean isSuccess() {
return result.equals("success");
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/ServiceError.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ServiceError {
private String code;
private String message;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/StatisticsInfoResponse.java
|
/*
* Copyright (c) 2021 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.v2.model.stats.StatisticsInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class StatisticsInfoResponse {
@JsonProperty("result")
private String result;
@JsonProperty("server")
private String server;
@JsonProperty("time")
private double time;
@JsonProperty("itime")
private double itime;
@JsonProperty("error")
private InstanceError error;
@JsonProperty("data")
private StatisticsInfo data;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
public boolean isSuccess() {
return result.equals("success");
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/TaxonomiesResponse.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import ai.expert.nlapi.v2.model.TaxonomyInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaxonomiesResponse {
private List<TaxonomyInfo> taxonomies;
public TaxonomyInfo getTaxonomyByName(String name) throws NLApiException {
return taxonomies.stream()
.filter(taxonomy -> taxonomy.getName().equals(name))
.findAny()
.orElseThrow(() -> new NLApiException(NLApiErrorCode.REQUEST_UNKNOWN_TAXONOMY_ERROR));
}
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/TaxonomyModelResponse.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.v2.model.Taxonomy;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaxonomyModelResponse {
@JsonProperty("success")
private boolean success;
@JsonProperty("errors")
private List<ServiceError> errors;
@JsonProperty("data")
private List<Taxonomy> data;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/TaxonomyResponse.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.v2.model.Taxonomy;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaxonomyResponse {
@JsonProperty("success")
private boolean success;
@JsonProperty("errors")
private List<ServiceError> errors;
@JsonProperty("data")
private List<Taxonomy> data;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/message/TemplatesModelResponse.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.message;
import ai.expert.nlapi.v2.model.TemplateNamespace;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TemplatesModelResponse {
@JsonProperty("success")
private boolean success;
@JsonProperty("errors")
private List<ServiceError> errors;
@JsonProperty("data")
private List<TemplateNamespace> data;
@SneakyThrows
public String toJSON() {
ObjectMapper om = new ObjectMapper();
return om.writeValueAsString(this);
}
@SneakyThrows
public void prettyPrint() {
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/AnalyzeDocument.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.model;
import ai.expert.nlapi.v2.API;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class AnalyzeDocument {
private String content;
private API.Languages language;
private String version;
private List<KnowledgeEntry> knowledge;
private List<Token> tokens;
private List<Phrase> phrases;
private List<Sentence> sentences;
private List<Paragraph> paragraphs;
private List<MainSentence> mainSentences;
private List<MainPhrase> mainPhrases;
private List<MainLemma> mainLemmas;
private List<MainSyncon> mainSyncons;
private List<DocumentTopic> topics;
private List<Entity> entities;
private List<Relation> relations;
private Sentiment sentiment;
private List<Category> categories;
private List<Extraction> extractions;
private Map<String,Object> extraData;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Atom.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.*;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class Atom extends DocumentPosition {
private String type;
private String lemma;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/CategorizeDocument.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.model;
import ai.expert.nlapi.v2.API;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class CategorizeDocument {
private String content;
private API.Languages language;
private String version;
private List<Category> categories;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Category.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Category {
private String id;
private String label;
private List<String> hierarchy;
private Float score;
private Boolean winner;
private String namespace;
private Float frequency;
private List<DocumentPosition> positions;
private Map<String, Object> extraData;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/ContextInfo.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ContextInfo {
private String name;
private String description;
private List<ContextLanguageInfo> languages;
private String contract;
public ContextLanguageInfo getLanguagesByName(String name) throws NLApiException {
return languages.stream()
.filter(language -> language.getName().equals(name))
.findAny()
.orElseThrow(() -> new NLApiException(NLApiErrorCode.REQUEST_UNKNOWN_LANGUAGE_ERROR));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/ContextLanguageInfo.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import ai.expert.nlapi.v2.API;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ContextLanguageInfo {
private API.Languages code;
private String name;
private List<String> analyses;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Dependency.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Dependency {
private Long id;
private Long head;
private String label;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/DetectDocument.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.model;
import ai.expert.nlapi.v2.API;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class DetectDocument {
private String content;
private API.Languages language;
private String version;
private List<Category> categories;
private List<Extraction> extractions;
private List<Entity> entities;
private List<KnowledgeEntry> knowledge;
private List<Token> tokens;
private List<Phrase> phrases;
private List<Sentence> sentences;
private List<Paragraph> paragraphs;
private Map<String,Object> extraData;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Document.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.Value;
@Value
public class Document {
String text;
public static Document of(String text) {
return new Document(text);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/DocumentPosition.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DocumentPosition {
private long start;
private long end;
private Float score;
private List<Geometry> geometry;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/DocumentTopic.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DocumentTopic {
private Long id;
private String label;
private Float score;
private Boolean winner;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Entity.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Entity {
private Long syncon;
private EntityType type;
private String lemma;
private Integer relevance;
private List<DocumentPosition> positions;
private List<InferredAttribute> attributes;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/EntityType.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public enum EntityType {
@JsonProperty("ADR")
ADR("Street address"),
@JsonProperty("ANM")
ANM("Animals"),
@JsonProperty("BLD")
BLD("Building"),
@JsonProperty("COM")
COM("Businesses / companies"),
@JsonProperty("DAT")
DAT("Date"),
@JsonProperty("DEV")
DEV("Device"),
@JsonProperty("DOC")
DOC("RequestDocument"),
@JsonProperty("EVN")
EVN("Event"),
@JsonProperty("FDD")
FDD("Food/beverage"),
@JsonProperty("GEA")
GEA("Physical geographic features"),
@JsonProperty("GEO")
GEO("Administrative geographic areas"),
@JsonProperty("GEX")
GEX("Extended geography"),
@JsonProperty("HOU")
HOU("Hours"),
@JsonProperty("LEN")
LEN("Legal entities"),
@JsonProperty("MAI")
MAI("Email address"),
@JsonProperty("MEA")
MEA("Measure"),
@JsonProperty("MMD")
MMD("Mass media"),
@JsonProperty("MON")
MON("Money"),
@JsonProperty("NPH")
NPH("Humans"),
@JsonProperty("ORG")
ORG("Organizations / societies / institutions"),
@JsonProperty("PCT")
PCT("Percentage"),
@JsonProperty("PHO")
PHO("Phone number"),
@JsonProperty("PPH")
PPH("Physical phenomena"),
@JsonProperty("PRD")
PRD("Product"),
@JsonProperty("VCL")
VCL("Vehicle"),
@JsonProperty("WEB")
WEB("Web address"),
@JsonProperty("WRK")
WRK("Work of human intelligence"),
@JsonProperty("NPR")
NPR("Proper noun"),
@JsonProperty("ENT")
ENT("Entity");
private final String description;
EntityType(String description) {
this.description = description;
}
public static EntityType fromDescription(String description) {
for(EntityType b : EntityType.values()) {
if(String.valueOf(b.description).equals(description)) {
return b;
}
}
return null;
}
public String getDescription() {
return description;
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Extraction.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Extraction {
private String namespace;
private String template;
private Float score;
private List<ExtractionField> fields;
private Map<String, Object> extraData;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/ExtractionField.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ExtractionField {
private String name;
private String value;
private Float score;
private List<DocumentPosition> positions;
private Map<String, Object> extraData;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Geometry.java
|
package ai.expert.nlapi.v2.model;
import lombok.Data;
import java.util.List;
@Data
public class Geometry {
private Integer page, pageWidth, pageHeight;
private List<Integer> box;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/InferredAttribute.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class InferredAttribute {
private String attribute;
private String lemma;
private Long syncon;
private String type;
private List<InferredAttribute> attributes;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/KnowledgeEntry.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class KnowledgeEntry {
private Long syncon;
private String label;
private List<Property> properties;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/LanguageInfo.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import ai.expert.nlapi.v2.API;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LanguageInfo {
private API.Languages code;
private String name;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/MainLemma.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MainLemma {
private String value;
private Float score;
private List<DocumentPosition> positions;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/MainPhrase.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MainPhrase {
private String value;
private Float score;
private List<DocumentPosition> positions;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/MainSentence.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.*;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MainSentence extends DocumentPosition {
private String value;
private Float score;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/MainSyncon.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MainSyncon {
private Long syncon;
private String lemma;
private Float score;
private List<DocumentPosition> positions;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Options.java
|
/*
* Copyright (c) 2020 original authors
*
* 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.Value;
import java.util.List;
import java.util.Map;
@Value
public class Options {
List<String> analysis;
List<String> features;
Map<String,Object> extra;
public static Options of(List<String> analysis, List<String> features) {
return new Options(analysis, features,null);
}
public static Options of(List<String> analysis, List<String> features, Map<String,Object> extra) {
return new Options(analysis, features,extra);
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/POSTag.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public enum POSTag {
@JsonProperty("ADJ")
ADJ("adjective"),
@JsonProperty("ADP")
ADP("adposition"),
@JsonProperty("ADV")
ADV("adverb"),
@JsonProperty("AUX")
AUX("auxiliary"),
@JsonProperty("CCONJ")
CCONJ("coordinating conjunction"),
@JsonProperty("DET")
DET("determiner"),
@JsonProperty("INTJ")
INTJ("interjection"),
@JsonProperty("NOUN")
NOUN("noun"),
@JsonProperty("NUM")
NUM("numeral"),
@JsonProperty("PART")
PART("particle"),
@JsonProperty("PRON")
PRON("pronoun"),
@JsonProperty("PROPN")
PROPN("proper noun"),
@JsonProperty("PUNCT")
PUNCT("punctuation"),
@JsonProperty("SCONJ")
SCONJ("subordinating conjunction"),
@JsonProperty("SYM")
SYM("symbol"),
@JsonProperty("VERB")
VERB("verb"),
@JsonProperty("X")
X("other");
private final String description;
POSTag(String description) {
this.description = description;
}
public static POSTag fromDescription(String description) {
for(POSTag b : POSTag.values()) {
if(String.valueOf(b.description).equals(description)) {
return b;
}
}
return null;
}
public String getDescription() {
return description;
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Paragraph.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.*;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class Paragraph extends DocumentPosition {
private List<Long> sentences;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Phrase.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.*;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class Phrase extends DocumentPosition {
private List<Long> tokens;
private PhraseType type;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/PhraseType.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
public enum PhraseType {
AP("Adjective Phrase"),
CP("Conjunction Phrase"),
CR("Blank lines"),
DP("Adverb Phrase"),
NP("Noun Phrase"),
PN("Nominal Predicate "),
PP("Preposition Phrase"),
RP("Relative Phrase"),
VP("Verb Phrase"),
NA("Not Applicable");
private final String description;
PhraseType(String description) {
this.description = description;
}
public static PhraseType fromDescription(String description) {
for(PhraseType b : PhraseType.values()) {
if(String.valueOf(b.description).equals(description)) {
return b;
}
}
return null;
}
public String getDescription() {
return description;
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Property.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Property {
private String type;
private String value;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/RelatedItem.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RelatedItem {
private String relation;
private Long syncon;
private String type;
private String lemma;
private String text;
private int relevance;
private long phrase;
private List<RelatedItem> related;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Relation.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Relation {
private RelationVerb verb;
private List<RelatedItem> related;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/RelationVerb.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RelationVerb {
private String text;
private String lemma;
private Long syncon;
private String type;
private Long phrase;
private long relevance;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/ResourceInfo.java
|
/*
* Copyright (c) 2021 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResourceInfo {
private String name;
private boolean busy;
private boolean compressed;
@JsonProperty("static")
private boolean is_static;
private List<ResourceProperty> properties;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/ResourceProperty.java
|
/*
* Copyright (c) 2021 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResourceProperty {
private String key;
private String value;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Sentence.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.*;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class Sentence extends DocumentPosition {
private List<Long> phrases;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Sentiment.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Sentiment {
private Double overall;
private Double negativity;
private Double positivity;
private List<SentimentItem> items;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/SentimentItem.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SentimentItem {
private String lemma;
private Long syncon;
private Double sentiment;
private VSyncon vsyn;
private List<SentimentItem> items;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Taxonomy.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Taxonomy {
private String namespace;
private List<TaxonomyCategory> taxonomy;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/TaxonomyCategory.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaxonomyCategory {
private String id;
private String label;
private List<TaxonomyCategory> categories;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/TaxonomyInfo.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import ai.expert.nlapi.exceptions.NLApiErrorCode;
import ai.expert.nlapi.exceptions.NLApiException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaxonomyInfo {
private String name;
private String contract;
private String description;
private List<LanguageInfo> languages;
public LanguageInfo getLanguagesByName(String name) throws NLApiException {
return languages.stream()
.filter(language -> language.getName().equals(name))
.findAny()
.orElseThrow(() -> new NLApiException(NLApiErrorCode.REQUEST_UNKNOWN_LANGUAGE_ERROR));
}
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Template.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Template {
private String name;
private List<TemplateField> fields;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/TemplateField.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TemplateField {
private String name;
private String type;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/TemplateNamespace.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TemplateNamespace {
private String namespace;
private List<Template> templates;
}
|
0
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2
|
java-sources/ai/expert/nlapi-java-sdk/2.7.0/ai/expert/nlapi/v2/model/Token.java
|
/*
* Copyright (c) 2020 original authors
*
* Licensed under the Apache License, Versions 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
*
* https://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 ai.expert.nlapi.v2.model;
import lombok.*;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class Token extends DocumentPosition {
private Long syncon;
private TokenType type;
private POSTag pos;
private String lemma;
private Dependency dependency;
private String morphology;
private Long paragraph;
private Long sentence;
private Long phrase;
private List<Atom> atoms;
private VSyncon vsyn;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.