public void ProcessInput(string input) { logger.LogDebug($"ProcessInput:'{input}'"); TokenCollection collection = input; var sentenceBuilder = new SentenceBuilder(); foreach (var token in collection.TextTokens) { string nomalized = token.Normalize(); var def = EnglishDictionary.Lookup(nomalized); if (def == null) { logger.LogWarn($"Defintion for {nomalized} not found"); } else { logger.LogDebug($"Defintion for {nomalized}: {def.ToJson()}"); sentenceBuilder.Add(def); } } SentenceExecutionOptions executionOptions = sentenceBuilder.BuildOptions(); if (executionOptions.IsExecutable()) { executionOptions.ResolveAndExecute(sentenceBuilder); } }
public SentenceExecutionOptions BuildOptions() { var result = new SentenceExecutionOptions(); logger.LogWarn($"{nameof(BuildOptions)} is only a prototype"); var listIndex = Words.IndexOf(x => x.Word == "list"); var theIndex = Words.IndexOf(x => x.Word == "the"); var whatIndex = Words.IndexOf(x => x.Word == "what"); var areIndex = Words.IndexOf(x => x.Word == "are"); if ( ((listIndex > -1 && theIndex > -1) && theIndex == listIndex + 1) || (whatIndex > -1 && whatIndex + 1 == areIndex && areIndex + 1 == theIndex) ) { result.Executables.Add("List"); } else { logger.LogWarn($"{nameof(BuildOptions)} did not find an executable phrase"); } return(result); }