Search in sources :

Example 11 with SupportedLanguage

use of ai.saiy.android.localisation.SupportedLanguage in project Saiy-PS by brandall76.

the class CustomCommandHelper method commandExists.

/**
 * Check if the keyphrase for the custom command already exists
 *
 * @param ctx           the application context
 * @param customCommand the prepared {@link CustomCommand}
 * @return true if the keyphrase exists, false otherwise
 */
public boolean commandExists(@NonNull final Context ctx, @NonNull final CustomCommand customCommand) {
    final ArrayList<CustomCommandContainer> customCommandContainerArray = getCustomCommands(ctx);
    if (UtilsList.notNaked(customCommandContainerArray)) {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "have commands");
        }
        final SupportedLanguage sl = SupportedLanguage.getSupportedLanguage(UtilsLocale.stringToLocale(customCommand.getVRLocale()));
        final Locale loc = sl.getLocale();
        for (final CustomCommandContainer ccc : customCommandContainerArray) {
            if (ccc.getKeyphrase().toLowerCase(loc).trim().matches(customCommand.getKeyphrase().toLowerCase(loc).trim())) {
                if (DEBUG) {
                    MyLog.i(CLS_NAME, "keyphrase matched: " + ccc.getKeyphrase() + " ~ " + customCommand.getKeyphrase());
                }
                return true;
            }
        }
        if (DEBUG) {
            MyLog.i(CLS_NAME, "command is not a duplicate");
        }
    } else {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "no commands");
        }
    }
    return false;
}
Also used : UtilsLocale(ai.saiy.android.utils.UtilsLocale) Locale(java.util.Locale) SupportedLanguage(ai.saiy.android.localisation.SupportedLanguage)

Example 12 with SupportedLanguage

use of ai.saiy.android.localisation.SupportedLanguage in project Saiy-PS by brandall76.

the class MemoryHelper method getUnknown.

/**
 * No {@link Memory} was stored, so we need to let the user know. We get the utterance we will
 * announce from the {@link PersonalityResponse} class.
 *
 * @param ctx the application context
 * @return a constructed {@link Memory} object
 */
private static Memory getUnknown(@NonNull final Context ctx) {
    final String vrLanguage = SPH.getVRLocale(ctx).toString();
    final String ttsLanguage = SPH.getTTSLocale(ctx).toString();
    final ArrayList<String> utteranceArray = new ArrayList<>();
    final int action = LocalRequest.ACTION_SPEAK_ONLY;
    final CC command = CC.COMMAND_UNKNOWN;
    final int condition = Condition.CONDITION_NONE;
    final SupportedLanguage sl = SupportedLanguage.getSupportedLanguage(SPH.getVRLocale(ctx));
    final String utterance = PersonalityResponse.getNoMemory(ctx, sl);
    return new Memory(action, vrLanguage, ttsLanguage, utterance, utteranceArray, command, condition, sl);
}
Also used : CC(ai.saiy.android.command.helper.CC) SupportedLanguage(ai.saiy.android.localisation.SupportedLanguage) ArrayList(java.util.ArrayList)

Aggregations

SupportedLanguage (ai.saiy.android.localisation.SupportedLanguage)12 Locale (java.util.Locale)5 UtilsLocale (ai.saiy.android.utils.UtilsLocale)4 UtilsString (ai.saiy.android.utils.UtilsString)3 Bundle (android.os.Bundle)3 LocalRequest (ai.saiy.android.service.helper.LocalRequest)2 Intent (android.content.Intent)2 Pair (android.util.Pair)2 ArrayList (java.util.ArrayList)2 BlackListHelper (ai.saiy.android.api.helper.BlackListHelper)1 Regex (ai.saiy.android.api.request.Regex)1 SaiyKeyphrase (ai.saiy.android.api.request.SaiyKeyphrase)1 Speaker (ai.saiy.android.cognitive.identity.provider.microsoft.Speaker)1 CC (ai.saiy.android.command.helper.CC)1 CustomCommand (ai.saiy.android.custom.CustomCommand)1 ExecuteIntent (ai.saiy.android.intent.ExecuteIntent)1 Resolve (ai.saiy.android.nlu.local.Resolve)1 UtilsBundle (ai.saiy.android.utils.UtilsBundle)1