Please be patient and read my current scenario. My question is below.
My application takes in speech input and is successfully able to group words that match together to form either one word or a group of words - called phrases; be it a
pet, or a
I have a master list of the phrases that are allowed and are stored in their respective arrays. So I have the following arrays
validPetsArray, and a
A new array of phrases is returned each and every time the user stops speaking.
NSArray *phrasesBeingFedIn = @[@"CHARLIE", @"EAT", @"AT TEN O CLOCK", @"CAT", @"DOG", "URINATE", @"CHILDREN", @"ITS TIME TO", @"PLAY"];
Knowing that its ok to have the following combination to create a command:
COMMAND 1: NAME + ACTION + TIME FRAME COMMAND 2: PET + ACTION COMMAND n: n + n, .. + n //In the example above, only the groups of phrases 'Charlie eat at ten o clock' and 'dog urinate' //would be valid commands, the phrase 'cat' would not qualify any of the commands //and will therefor be ignored
What is the best way for me to parse through the phrases being fed in and determine which combination phrases will satisfy my list of commands?
POSSIBLE solution I've come up with One way is to step through the array and have if and else statements that check the phrases ahead and see if they satisfy any valid command patterns from the list, however my solution is not dynamic, I would have to add a new set of if and else statements for every single new command permutation I create.
My solution is not efficient. Any ideas on how I could go about creating something like this that will work and is dynamic no matter if I add a new command sequence of phrase combination?