Search in sources :

Example 1 with NLUCoerce

use of ai.saiy.android.nlu.NLUCoerce in project Saiy-PS by brandall76.

the class ResolveAPIAI method unpack.

public void unpack(@NonNull final String gsonResponse) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "unpacking");
    }
    final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
    final AIResponse response = gson.fromJson(gsonResponse, new TypeToken<AIResponse>() {
    }.getType());
    nluAPIAI = new NLUAPIAI(confidenceArray, resultsArray, response.getResult().getMetadata().getIntentName(), response.getResult().getParameters());
    new NLUCoerce(getNLUAPIAI(), getContext(), getSupportedLanguage(), getVRLocale(), getTTSLocale(), getConfidenceArray(), getResultsArray()).coerce();
}
Also used : AIResponse(ai.api.model.AIResponse) GsonBuilder(com.google.gson.GsonBuilder) TypeToken(com.google.gson.reflect.TypeToken) NLUCoerce(ai.saiy.android.nlu.NLUCoerce) Gson(com.google.gson.Gson)

Example 2 with NLUCoerce

use of ai.saiy.android.nlu.NLUCoerce in project Saiy-PS by brandall76.

the class ResolveNuance method unpack.

public void unpack(@NonNull final JSONObject payload) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "unpacking");
    }
    final GsonBuilder builder = new GsonBuilder();
    builder.disableHtmlEscaping();
    builder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
    final Gson gson = builder.create();
    nluNuance = gson.fromJson(payload.toString(), new TypeToken<NLUNuance>() {
    }.getType());
    new NLUCoerce(getNLUNuance(), getContext(), getSupportedLanguage(), getVRLocale(), getTTSLocale(), getConfidenceArray(), getResultsArray()).coerce();
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) NLUCoerce(ai.saiy.android.nlu.NLUCoerce) Gson(com.google.gson.Gson)

Example 3 with NLUCoerce

use of ai.saiy.android.nlu.NLUCoerce in project Saiy-PS by brandall76.

the class ResolveBluemix method unpack.

public void unpack(@NonNull final NLUBluemix nluBluemix) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "unpacking");
    }
    this.nluBluemix = nluBluemix;
    new NLUCoerce(getNLUBluemix(), getContext(), getSupportedLanguage(), getVRLocale(), getTTSLocale(), getConfidenceArray(), getResultsArray()).coerce();
}
Also used : NLUCoerce(ai.saiy.android.nlu.NLUCoerce)

Example 4 with NLUCoerce

use of ai.saiy.android.nlu.NLUCoerce in project Saiy-PS by brandall76.

the class ResolveMicrosoft method unpack.

public void unpack(@NonNull final String payload) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "unpacking");
    }
    final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
    nluMicrosoft = gson.fromJson(payload, NLUMicrosoft.class);
    new NLUCoerce(getNLUMicrosoft(), getContext(), getSupportedLanguage(), getVRLocale(), getTTSLocale(), getConfidenceArray(), getResultsArray()).coerce();
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) NLUCoerce(ai.saiy.android.nlu.NLUCoerce) Gson(com.google.gson.Gson)

Example 5 with NLUCoerce

use of ai.saiy.android.nlu.NLUCoerce in project Saiy-PS by brandall76.

the class ResolveWit method unpack.

public void unpack(@NonNull final NLUWit nluWit) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "unpacking");
    }
    this.nluWit = nluWit;
    new NLUCoerce(getNLUWit(), getContext(), getSupportedLanguage(), getVRLocale(), getTTSLocale(), getConfidenceArray(), getResultsArray()).coerce();
}
Also used : NLUCoerce(ai.saiy.android.nlu.NLUCoerce)

Aggregations

NLUCoerce (ai.saiy.android.nlu.NLUCoerce)6 Gson (com.google.gson.Gson)4 GsonBuilder (com.google.gson.GsonBuilder)4 AIResponse (ai.api.model.AIResponse)1 TypeToken (com.google.gson.reflect.TypeToken)1