Beispiel #1
0
        public List <SpeechResult> Process(string text)
        {
            var command = new InputStack(text);

            var resultList = new SpeechResultList();

            while (command.Count > 0)
            {
                if (string.IsNullOrEmpty(command.Peek()))
                {
                    command.Pop();
                    continue;
                }

                SortedSet <SpeechResult> results = new SortedSet <SpeechResult>();
                foreach (var speechCommand in Commands)
                {
                    var result = speechCommand.Process(command);
                    if (result != null)
                    {
                        results.Add(result);
                    }
                }

                if (results.Count > 0)
                {
                    SpeechResult bestResult = results.First();
                    for (int i = 0; i < bestResult.TokenCount; i++)
                    {
                        command.Pop();
                    }

                    resultList.Add(bestResult);
                }
                else
                {
                    command.Pop();
                }
            }

            resultList.Add(new SpeechResult(TokenType.Text, "Enter", 0, 0));
            resultList.ForEach(x => x.SendCommand());

            return(resultList);
        }
Beispiel #2
0
 public int Compare(SpeechResult x, SpeechResult y)
 {
     return(x.Score.CompareTo(y.Score));
 }