/// <summary> /// Break command down to syllables. Check if the replacer should be run /// </summary> /// <param name="command">Command to break down</param> public void CommandToSyllables(string command) { if (Command == null) { Command = command; RunSyllableReplacer = SylReplacer.Run(command); CommandSyllables = getSyllables(command); } }
/// <summary> /// Try to match the current command to the key. /// </summary> /// <param name="key">Key to match check for</param> /// <returns>True if succesfully matched</returns> public bool Match(string key) { // Get the syllables of the base command string[] baseSyls = getSyllables(key); if (RunSyllableReplacer) { var commandReps = SylReplacer.GetReplacements(CommandSyllables, "gay"); var baseReps = SylReplacer.GetReplacements(baseSyls, "gay"); for (int i = 0; i < commandReps.Length; i++) { for (int j = 0; j < baseReps.Length; j++) { //Console.WriteLine("Comparing: " + commandReps[i] + " | " + baseReps[j]); // Check if syllable comparison is enough if (commandReps[i] == baseReps[j]) { return(true); } // Do a consonant based comparison if (ConComparator.Compare(commandReps[i], baseReps[j])) { return(true); } } } } else { //Console.WriteLine("Comparing: " + Command + " | " + key); // Do a consonant based comparison if (ConComparator.Compare(Command, key)) { return(true); } } return(false); }