use of ai.saiy.android.nlu.microsoft.Entity in project Saiy-PS by brandall76.
the class NLUCoerce method validateNLUNLUMicrosoft.
/**
* Validate the parameters prior to use.
*
* @param nluMicrosoft the {@link NLUMicrosoft} response object
* @return true if the minimum parameters are present, false otherwise.
*/
private boolean validateNLUNLUMicrosoft(@NonNull final NLUMicrosoft nluMicrosoft) {
if (DEBUG) {
MyLog.i(CLS_NAME, "validateNLUNLUMicrosoft");
}
if (UtilsString.notNaked(nluMicrosoft.getQuery())) {
if (DEBUG) {
MyLog.i(CLS_NAME, "query: " + nluMicrosoft.getQuery());
}
final List<Intent> intents = nluMicrosoft.getIntents();
if (UtilsList.notNaked(intents)) {
for (final Intent i : intents) {
if (UtilsString.notNaked(i.getIntent())) {
if (DEBUG) {
MyLog.i(CLS_NAME, "getIntent: " + i.getIntent());
MyLog.i(CLS_NAME, "getScore: " + i.getScore());
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "validateNLUNLUMicrosoft: intent naked");
}
return false;
}
}
final List<Entity> entities = nluMicrosoft.getEntities();
if (entities != null) {
final int entitiesSize = entities.size();
if (entitiesSize > 0) {
for (int i = 0; i < entitiesSize; i++) {
if (UtilsString.notNaked(entities.get(i).getEntity()) && UtilsString.notNaked(entities.get(i).getType())) {
if (DEBUG) {
MyLog.i(CLS_NAME, "getEntity: " + entities.get(i).getEntity());
MyLog.i(CLS_NAME, "getType: " + entities.get(i).getType());
MyLog.i(CLS_NAME, "getStartIndex: " + entities.get(i).getStartIndex());
MyLog.i(CLS_NAME, "getEndIndex: " + entities.get(i).getEndIndex());
MyLog.i(CLS_NAME, "getScore: " + entities.get(i).getScore());
}
if (i == (entitiesSize - 1)) {
return true;
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "validateNLUNLUMicrosoft: entity/type naked");
}
break;
}
}
} else {
if (DEBUG) {
MyLog.i(CLS_NAME, "validateNLUNLUMicrosoft: no entities to examine");
}
return true;
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "validateNLUNLUMicrosoft: entities null");
}
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "validateNLUNLUMicrosoft: intents naked");
}
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "validateNLUNLUMicrosoft: query naked");
}
}
return false;
}