use of ai.saiy.android.nlu.saiy.ContextValue in project Saiy-PS by brandall76.
the class NLUCoerce method validateNLUSaiy.
/**
* Validate the parameters prior to use.
*
* @param nluSaiy the {@link NLUSaiy} response object
* @return true if the minimum parameters are present, false otherwise.
*/
private boolean validateNLUSaiy(@NonNull final NLUSaiy nluSaiy) {
if (DEBUG) {
MyLog.i(CLS_NAME, "validateNLUSaiy");
}
final List<String> results = nluSaiy.getResults();
if (UtilsList.notNaked(results)) {
final float[] confidence = nluSaiy.getConfidence();
if (UtilsList.notNaked(confidence)) {
final List<ai.saiy.android.nlu.saiy.Intent> intents = nluSaiy.getIntents();
if (UtilsList.notNaked(intents)) {
for (final ai.saiy.android.nlu.saiy.Intent intent : intents) {
if (DEBUG) {
MyLog.i(CLS_NAME, "getIntent: " + intent.getIntent());
MyLog.i(CLS_NAME, "getType: " + intent.getConfidence());
}
final List<ai.saiy.android.nlu.saiy.Entity> entities = intent.getEntities();
if (UtilsList.notNaked(entities)) {
final int entitiesSize = entities.size();
for (int i = 0; i < entitiesSize; i++) {
if (DEBUG) {
MyLog.i(CLS_NAME, "getVoiceName: " + entities.get(i).getName());
MyLog.i(CLS_NAME, "getVoiceName: " + entities.get(i).getValue());
MyLog.i(CLS_NAME, "getVoiceName: " + entities.get(i).getConfidence());
MyLog.i(CLS_NAME, "getContextual: " + entities.get(i).getContextual());
MyLog.i(CLS_NAME, "getVoiceName: " + Arrays.toString(entities.get(i).getIndex()));
}
final List<ai.saiy.android.nlu.saiy.Context> contexts = entities.get(i).getContextual();
for (final ai.saiy.android.nlu.saiy.Context context : contexts) {
if (DEBUG) {
MyLog.i(CLS_NAME, "getContext: " + context.getContext());
MyLog.i(CLS_NAME, "getConfidence: " + context.getConfidence());
}
final List<ContextValue> contextValues = context.getContextValues();
for (final ContextValue contextValue : contextValues) {
if (DEBUG) {
MyLog.i(CLS_NAME, "getIdentifier: " + contextValue.getIdentifier());
}
}
}
if (i == (entitiesSize - 1)) {
return true;
}
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "validateNLUSaiy: entities naked");
}
}
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "validateNLUSaiy: intents naked");
}
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "validateNLUSaiy: confidence naked");
}
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "validateNLUSaiy: results naked");
}
}
return false;
}
Aggregations