use of ai.saiy.android.command.spell.CommandSpellValues in project Saiy-PS by brandall76.
the class NLUAPIAIHelper method prepareCommand.
/**
* Coerce the parameters into a {@link CommandRequest} object
*
* @param ctx the application context
* @param commandRequest the {@link CommandRequest}
* @param sl the {@link SupportedLanguage}
* @param parameters the parameters unique to the NLP provider
* @return the populated {@link CommandRequest} object
*/
public CommandRequest prepareCommand(@NonNull final Context ctx, @NonNull final CommandRequest commandRequest, @NonNull final SupportedLanguage sl, @NonNull final HashMap<String, JsonElement> parameters) {
switch(commandRequest.getCC()) {
case COMMAND_UNKNOWN:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_UNKNOWN");
}
break;
case COMMAND_CANCEL:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_CANCEL");
}
break;
case COMMAND_SPELL:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SPELL");
}
final CommandSpellValues csv = new CommandSpellValues();
if (UtilsMap.notNaked(parameters)) {
if (parameters.containsKey(NLUConstants.TEXT_TO_SPELL)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SPELL: extraction complete");
}
csv.setText(parameters.get(NLUConstants.TEXT_TO_SPELL).getAsString());
commandRequest.setResolved(true);
}
}
commandRequest.setVariableData(csv);
break;
case COMMAND_TRANSLATE:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TRANSLATE");
}
final CommandTranslateValues ctv = new CommandTranslateValues();
if (UtilsMap.notNaked(parameters)) {
if (parameters.containsKey(NLUConstants.LANGUAGE) && parameters.containsKey(NLUConstants.TEXT_TO_TRANSLATE)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TRANSLATE: extraction complete");
}
ctv.setText(parameters.get(NLUConstants.TEXT_TO_TRANSLATE).getAsString());
ctv.setLanguage(parameters.get(NLUConstants.LANGUAGE).getAsString());
commandRequest.setResolved(true);
}
}
commandRequest.setVariableData(ctv);
break;
case COMMAND_SONG_RECOGNITION:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SONG_RECOGNITION: extraction complete");
}
commandRequest.setResolved(true);
break;
case COMMAND_PARDON:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_PARDON: extraction complete");
}
commandRequest.setResolved(true);
break;
case COMMAND_USER_NAME:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_NAME");
}
final CommandUserNameValues cunv = new CommandUserNameValues();
if (UtilsMap.notNaked(parameters)) {
if (parameters.containsKey(NLUConstants.NAME_USER)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_NAME: extraction complete");
}
cunv.setName(parameters.get(NLUConstants.NAME_USER).getAsString());
commandRequest.setResolved(true);
}
}
commandRequest.setVariableData(cunv);
break;
case COMMAND_BATTERY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_BATTERY");
}
final CommandBatteryValues cbv = new CommandBatteryValues();
if (UtilsMap.notNaked(parameters)) {
if (parameters.containsKey(NLUConstants.BATTERY_TYPE)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_BATTERY: extraction complete");
}
cbv.setTypeString(parameters.get(NLUConstants.BATTERY_TYPE).getAsString());
cbv.setType(cbv.stringToType(ctx, sl, parameters.get(NLUConstants.BATTERY_TYPE).getAsString()));
commandRequest.setResolved(true);
}
}
commandRequest.setVariableData(cbv);
break;
case COMMAND_HOTWORD:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_HOTWORD");
}
commandRequest.setResolved(true);
break;
case COMMAND_EMOTION:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_EMOTION");
}
commandRequest.setResolved(true);
break;
case COMMAND_VOICE_IDENTIFY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_VOICE_IDENTIFY");
}
commandRequest.setResolved(true);
break;
case COMMAND_TASKER:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TASKER");
}
final CommandTaskerValues taskerValues = new CommandTaskerValues();
if (UtilsMap.notNaked(parameters)) {
if (parameters.containsKey(NLUConstants.TASKER_TASK_NAME)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TASKER: extraction complete");
}
taskerValues.setTaskName(parameters.get(NLUConstants.TASKER_TASK_NAME).getAsString());
commandRequest.setResolved(true);
}
}
commandRequest.setVariableData(taskerValues);
break;
case COMMAND_WOLFRAM_ALPHA:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_WOLFRAM_ALPHA");
}
final CommandWolframAlphaValues cwav = new CommandWolframAlphaValues();
if (UtilsMap.notNaked(parameters)) {
if (parameters.containsKey(NLUConstants.QUESTION_CONTENT)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_WOLFRAM_ALPHA: extraction complete");
}
cwav.setQuestion(parameters.get(NLUConstants.QUESTION_CONTENT).getAsString());
commandRequest.setResolved(true);
}
}
commandRequest.setVariableData(cwav);
break;
case COMMAND_EMPTY_ARRAY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_EMPTY_ARRAY");
}
break;
case COMMAND_USER_CUSTOM:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_CUSTOM");
}
break;
case COMMAND_SOMETHING_WEIRD:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SOMETHING_WEIRD");
}
break;
}
return commandRequest;
}
use of ai.saiy.android.command.spell.CommandSpellValues in project Saiy-PS by brandall76.
the class NLUMicrosoftHelper method prepareCommand.
/**
* Coerce the parameters into a {@link CommandRequest} object
*
* @param ctx the application context
* @param commandRequest the {@link CommandRequest}
* @param sl the {@link SupportedLanguage}
* @param entities the parameters unique to the NLP provider
* @return the populated {@link CommandRequest} object
*/
public CommandRequest prepareCommand(@NonNull final Context ctx, @NonNull final CommandRequest commandRequest, @NonNull final SupportedLanguage sl, @NonNull final List<Entity> entities) {
switch(commandRequest.getCC()) {
case COMMAND_UNKNOWN:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_UNKNOWN");
}
break;
case COMMAND_CANCEL:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_CANCEL");
}
break;
case COMMAND_SONG_RECOGNITION:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SONG_RECOGNITION: extraction complete");
}
commandRequest.setResolved(true);
break;
case COMMAND_SPELL:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SPELL");
}
final CommandSpellValues csv = new CommandSpellValues();
for (final Entity e : entities) {
if (e.getType().matches(NLUConstants.TEXT_TO_SPELL)) {
csv.setText(e.getEntity());
csv.setStartIndex(e.getStartIndex());
csv.setEndIndex(e.getEndIndex());
commandRequest.setResolved(true);
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SPELL: extraction complete");
}
break;
}
}
commandRequest.setVariableData(csv);
break;
case COMMAND_TRANSLATE:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TRANSLATE");
}
final CommandTranslateValues ctv = new CommandTranslateValues();
for (final Entity e : entities) {
if (e.getType().matches(NLUConstants.TRANSLATE_LANGUAGE)) {
ctv.setLanguage(e.getEntity());
ctv.setLanguageStartIndex(e.getStartIndex());
ctv.setLanguageEndIndex(e.getEndIndex());
} else if (e.getType().matches(NLUConstants.TEXT_TO_TRANSLATE)) {
ctv.setText(e.getEntity());
ctv.setTextStartIndex(e.getStartIndex());
ctv.setTextEndIndex(e.getEndIndex());
}
if (UtilsString.notNaked(ctv.getLanguage()) && UtilsString.notNaked(ctv.getText())) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TRANSLATE: extraction complete");
}
commandRequest.setResolved(true);
break;
}
}
commandRequest.setVariableData(ctv);
break;
case COMMAND_PARDON:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_PARDON: extraction complete");
}
commandRequest.setResolved(true);
break;
case COMMAND_USER_NAME:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_NAME");
}
final CommandUserNameValues cunv = new CommandUserNameValues();
for (final Entity e : entities) {
if (e.getType().matches(NLUConstants.NAME_USER)) {
cunv.setName(e.getEntity());
cunv.setStartIndex(e.getStartIndex());
cunv.setEndIndex(e.getEndIndex());
commandRequest.setResolved(true);
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_NAME: extraction complete");
}
break;
}
}
commandRequest.setVariableData(cunv);
break;
case COMMAND_BATTERY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_BATTERY");
}
final CommandBatteryValues cbv = new CommandBatteryValues();
for (final Entity e : entities) {
if (e.getType().matches(NLUConstants.BATTERY_TYPE)) {
cbv.setType(cbv.stringToType(ctx, sl, e.getEntity()));
cbv.setTypeString(e.getEntity());
cbv.setStartIndex(e.getStartIndex());
cbv.setEndIndex(e.getEndIndex());
commandRequest.setResolved(true);
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_BATTERY: extraction complete");
}
break;
}
}
commandRequest.setVariableData(cbv);
break;
case COMMAND_HOTWORD:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_HOTWORD");
}
commandRequest.setResolved(true);
break;
case COMMAND_EMOTION:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_EMOTION");
}
commandRequest.setResolved(true);
break;
case COMMAND_VOICE_IDENTIFY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_VOICE_IDENTIFY");
}
commandRequest.setResolved(true);
break;
case COMMAND_TASKER:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TASKER");
}
final CommandTaskerValues taskerValues = new CommandTaskerValues();
for (final Entity e : entities) {
if (e.getType().matches(NLUConstants.TASKER_TASK_NAME)) {
taskerValues.setTaskName(e.getEntity());
taskerValues.setStartIndex(e.getStartIndex());
taskerValues.setEndIndex(e.getEndIndex());
commandRequest.setResolved(true);
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TASKER: extraction complete");
}
break;
}
}
commandRequest.setVariableData(taskerValues);
break;
case COMMAND_WOLFRAM_ALPHA:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_WOLFRAM_ALPHA");
}
final CommandWolframAlphaValues cwav = new CommandWolframAlphaValues();
for (final Entity e : entities) {
if (e.getType().matches(NLUConstants.QUESTION_CONTENT)) {
cwav.setQuestion(e.getEntity());
cwav.setStartIndex(e.getStartIndex());
cwav.setEndIndex(e.getEndIndex());
commandRequest.setResolved(true);
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_WOLFRAM_ALPHA: extraction complete");
}
break;
}
}
commandRequest.setVariableData(cwav);
break;
case COMMAND_EMPTY_ARRAY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_EMPTY_ARRAY");
}
break;
case COMMAND_USER_CUSTOM:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_CUSTOM");
}
break;
case COMMAND_SOMETHING_WEIRD:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SOMETHING_WEIRD");
}
break;
}
return commandRequest;
}
use of ai.saiy.android.command.spell.CommandSpellValues in project Saiy-PS by brandall76.
the class NLUSaiyHelper method prepareCommand.
/**
* Coerce the parameters into a {@link CommandRequest} object
*
* @param ctx the application context
* @param commandRequest the {@link CommandRequest}
* @param sl the {@link SupportedLanguage}
* @param entities the parameters unique to the NLP provider
* @return the populated {@link CommandRequest} object
*/
public CommandRequest prepareCommand(@NonNull final android.content.Context ctx, @NonNull final CommandRequest commandRequest, @NonNull final SupportedLanguage sl, @NonNull final List<Entity> entities) {
switch(commandRequest.getCC()) {
case COMMAND_UNKNOWN:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_UNKNOWN");
}
break;
case COMMAND_CANCEL:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_CANCEL");
}
break;
case COMMAND_SPELL:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SPELL");
}
final CommandSpellValues csv = new CommandSpellValues();
for (final Entity e : entities) {
if (e.getName().matches(NLUConstants.NAME_USER)) {
csv.setText(e.getValue());
csv.setStartIndex(e.getIndex()[0]);
csv.setEndIndex(e.getIndex()[1]);
commandRequest.setResolved(true);
break;
}
}
commandRequest.setVariableData(csv);
break;
case COMMAND_TRANSLATE:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TRANSLATE");
}
final CommandTranslateValues ctv = new CommandTranslateValues();
for (final Entity e : entities) {
if (e.getName().matches(NLUConstants.TRANSLATE_LANGUAGE)) {
ctv.setLanguage(e.getValue());
ctv.setLanguageStartIndex(e.getIndex()[0]);
ctv.setLanguageEndIndex(e.getIndex()[1]);
} else if (e.getName().matches(NLUConstants.TEXT_TO_TRANSLATE)) {
ctv.setText(e.getValue());
ctv.setTextStartIndex(e.getIndex()[0]);
ctv.setTextEndIndex(e.getIndex()[1]);
}
if (UtilsString.notNaked(ctv.getLanguage()) && UtilsString.notNaked(ctv.getText())) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TRANSLATE: extraction complete");
}
commandRequest.setResolved(true);
break;
}
}
commandRequest.setVariableData(ctv);
break;
case COMMAND_SONG_RECOGNITION:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SONG_RECOGNITION");
}
commandRequest.setResolved(true);
break;
case COMMAND_PARDON:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_PARDON");
}
commandRequest.setResolved(true);
break;
case COMMAND_USER_NAME:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_NAME");
}
final CommandUserNameValues cunv = new CommandUserNameValues();
for (final Entity e : entities) {
if (e.getName().matches(NLUConstants.NAME_USER)) {
cunv.setName(e.getValue());
cunv.setStartIndex(e.getIndex()[0]);
cunv.setEndIndex(e.getIndex()[1]);
commandRequest.setResolved(true);
break;
}
}
commandRequest.setVariableData(cunv);
break;
case COMMAND_BATTERY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_BATTERY");
}
final CommandBatteryValues cbv = new CommandBatteryValues();
for (final Entity e : entities) {
if (e.getName().matches(NLUConstants.BATTERY_TYPE)) {
cbv.setTypeString(e.getValue());
cbv.setType(cbv.stringToType(ctx, sl, e.getValue()));
cbv.setStartIndex(e.getIndex()[0]);
cbv.setEndIndex(e.getIndex()[1]);
commandRequest.setResolved(true);
break;
}
}
commandRequest.setVariableData(cbv);
break;
case COMMAND_HOTWORD:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_HOTWORD");
}
commandRequest.setResolved(true);
break;
case COMMAND_EMOTION:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_EMOTION");
}
commandRequest.setResolved(true);
break;
case COMMAND_VOICE_IDENTIFY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_VOICE_IDENTIFY");
}
commandRequest.setResolved(true);
break;
case COMMAND_TASKER:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TASKER");
}
final CommandTaskerValues taskerValues = new CommandTaskerValues();
for (final Entity e : entities) {
if (e.getName().matches(NLUConstants.TASKER_TASK_NAME)) {
taskerValues.setTaskName(e.getValue());
taskerValues.setStartIndex(e.getIndex()[0]);
taskerValues.setEndIndex(e.getIndex()[1]);
commandRequest.setResolved(true);
break;
}
}
commandRequest.setVariableData(taskerValues);
break;
case COMMAND_WOLFRAM_ALPHA:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_WOLFRAM_ALPHA");
}
final CommandWolframAlphaValues cwav = new CommandWolframAlphaValues();
for (final Entity e : entities) {
if (e.getName().matches(NLUConstants.QUESTION_CONTENT)) {
cwav.setQuestion(e.getValue());
cwav.setStartIndex(e.getIndex()[0]);
cwav.setEndIndex(e.getIndex()[1]);
commandRequest.setResolved(true);
break;
}
}
commandRequest.setVariableData(cwav);
break;
case COMMAND_EMPTY_ARRAY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_EMPTY_ARRAY");
}
break;
case COMMAND_USER_CUSTOM:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_CUSTOM");
}
break;
case COMMAND_SOMETHING_WEIRD:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SOMETHING_WEIRD");
}
break;
}
return commandRequest;
}
use of ai.saiy.android.command.spell.CommandSpellValues in project Saiy-PS by brandall76.
the class NLUNuanceHelper method prepareCommand.
/**
* Coerce the parameters into a {@link CommandRequest} object
*
* @param ctx the application context
* @param commandRequest the {@link CommandRequest}
* @param sl the {@link SupportedLanguage}
* @param map the parameters unique to the NLP provider
* @return the populated {@link CommandRequest} object
*/
public CommandRequest prepareCommand(@NonNull final Context ctx, @NonNull final CommandRequest commandRequest, @NonNull final SupportedLanguage sl, @NonNull final Map<String, List<Concept>> map) {
switch(commandRequest.getCC()) {
case COMMAND_UNKNOWN:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_UNKNOWN");
}
break;
case COMMAND_CANCEL:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_CANCEL");
}
break;
case COMMAND_SPELL:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SPELL");
}
final CommandSpellValues csv = new CommandSpellValues();
for (final Map.Entry<String, List<Concept>> entry : map.entrySet()) {
final List<Concept> concepts = entry.getValue();
for (final Concept concept : concepts) {
if (entry.getKey().matches(NLUConstants.TEXT_TO_SPELL)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SPELL: extraction complete");
}
csv.setText(concept.getLiteral());
csv.setRanges(concept.getRanges());
commandRequest.setResolved(true);
break;
}
}
}
commandRequest.setVariableData(csv);
break;
case COMMAND_TRANSLATE:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TRANSLATE");
}
final CommandTranslateValues ctv = new CommandTranslateValues();
for (final Map.Entry<String, List<Concept>> entry : map.entrySet()) {
final List<Concept> concepts = entry.getValue();
for (final Concept concept : concepts) {
if (entry.getKey().matches(NLUConstants.TEXT_TO_TRANSLATE)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: TEXT_TO_TRANSLATE");
MyLog.i(CLS_NAME, "prepareCommand: getLiteral: " + concept.getLiteral());
MyLog.i(CLS_NAME, "prepareCommand: getRanges: " + Arrays.deepToString(concept.getRanges()));
}
ctv.setText(concept.getLiteral());
ctv.setTextRanges(concept.getRanges());
} else if (entry.getKey().matches(NLUConstants.LANGUAGE)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: TRANSLATE_LANGUAGE");
MyLog.i(CLS_NAME, "prepareCommand: getLiteral: " + concept.getLiteral());
MyLog.i(CLS_NAME, "prepareCommand: getRanges: " + Arrays.deepToString(concept.getRanges()));
}
ctv.setLanguage(concept.getLiteral().toLowerCase(sl.getLocale()));
ctv.setLanguageRanges(concept.getRanges());
}
if (UtilsString.notNaked(ctv.getLanguage()) && UtilsString.notNaked(ctv.getText())) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TRANSLATE: extraction complete");
}
commandRequest.setResolved(true);
break;
}
}
}
commandRequest.setVariableData(ctv);
break;
case COMMAND_SONG_RECOGNITION:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SONG_RECOGNITION: extraction complete");
}
commandRequest.setResolved(true);
break;
case COMMAND_PARDON:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_PARDON: extraction complete");
}
commandRequest.setResolved(true);
break;
case COMMAND_USER_NAME:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_NAME");
}
final CommandUserNameValues cunv = new CommandUserNameValues();
for (final Map.Entry<String, List<Concept>> entry : map.entrySet()) {
final List<Concept> concepts = entry.getValue();
for (final Concept concept : concepts) {
if (entry.getKey().matches(NLUConstants.NAME_USER)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_NAME: extraction complete");
}
cunv.setName(concept.getLiteral());
cunv.setRanges(concept.getRanges());
commandRequest.setResolved(true);
break;
}
}
}
commandRequest.setVariableData(cunv);
break;
case COMMAND_BATTERY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_BATTERY");
}
final CommandBatteryValues cbv = new CommandBatteryValues();
for (final Map.Entry<String, List<Concept>> entry : map.entrySet()) {
final List<Concept> concepts = entry.getValue();
for (final Concept concept : concepts) {
if (entry.getKey().matches(NLUConstants.BATTERY_TYPE)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_BATTERY: extraction complete");
}
cbv.setType(cbv.stringToType(ctx, sl, concept.getLiteral()));
cbv.setTypeString(concept.getLiteral());
cbv.setRanges(concept.getRanges());
commandRequest.setResolved(true);
break;
}
}
}
commandRequest.setVariableData(cbv);
break;
case COMMAND_HOTWORD:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_HOTWORD");
}
commandRequest.setResolved(true);
break;
case COMMAND_EMOTION:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_EMOTION");
}
commandRequest.setResolved(true);
break;
case COMMAND_VOICE_IDENTIFY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_VOICE_IDENTIFY");
}
commandRequest.setResolved(true);
break;
case COMMAND_TASKER:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TASKER");
}
final CommandTaskerValues taskerValues = new CommandTaskerValues();
for (final Map.Entry<String, List<Concept>> entry : map.entrySet()) {
final List<Concept> concepts = entry.getValue();
for (final Concept concept : concepts) {
if (entry.getKey().matches(NLUConstants.TASKER_TASK_NAME)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_TASKER: extraction complete");
}
taskerValues.setTaskName(concept.getLiteral());
taskerValues.setRanges(concept.getRanges());
commandRequest.setResolved(true);
break;
}
}
}
commandRequest.setVariableData(taskerValues);
break;
case COMMAND_WOLFRAM_ALPHA:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_WOLFRAM_ALPHA");
}
final CommandWolframAlphaValues cwav = new CommandWolframAlphaValues();
for (final Map.Entry<String, List<Concept>> entry : map.entrySet()) {
final List<Concept> concepts = entry.getValue();
for (final Concept concept : concepts) {
if (entry.getKey().matches(NLUConstants.QUESTION_CONTENT)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_WOLFRAM_ALPHA: extraction complete");
}
cwav.setQuestion(concept.getLiteral());
cwav.setRanges(concept.getRanges());
commandRequest.setResolved(true);
break;
}
}
}
commandRequest.setVariableData(cwav);
break;
case COMMAND_EMPTY_ARRAY:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_EMPTY_ARRAY");
}
break;
case COMMAND_USER_CUSTOM:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_USER_CUSTOM");
}
break;
case COMMAND_SOMETHING_WEIRD:
if (DEBUG) {
MyLog.i(CLS_NAME, "prepareCommand: COMMAND_SOMETHING_WEIRD");
}
break;
}
return commandRequest;
}
Aggregations