Exemple #1
0
        public override SpeechResult Process(InputStack command)
        {
            if (command.Count == 0)
            {
                return(null);
            }

            string commandText = "";

            //If there aren't enough tokens, we don't have a match
            if (numberOfWords > command.Count)
            {
                return(null);
            }

            for (int i = 0; i < numberOfWords; i++)
            {
                commandText += " " + command.ToList()[i].ToString();
            }

            commandText = commandText.Trim();
            if (commandText.Equals(phrase, StringComparison.OrdinalIgnoreCase))
            {
                return(new SpeechResult(TokenType.MultiWord, Value, 0, numberOfWords));
            }

            return(null);
        }
Exemple #2
0
        public override SpeechResult Process(InputStack command)
        {
            if (command.Count == 0)
            {
                return(null);
            }

            string c = command.Peek();

            switch (c)
            {
            case "one":
                c = "1";
                break;

            case "two":
                c = "2";
                break;

            case "three":
                c = "3";
                break;

            case "four":
                c = "4";
                break;

            case "five":
                c = "5";
                break;

            case "six":
                c = "6";
                break;

            case "seven":
                c = "7";
                break;

            case "eight":
                c = "8";
                break;

            case "nine":
                c = "9";
                break;

            case "zero":
                c = "0";
                break;
            }


            if (int.TryParse(c, out int number))
            {
                return(new SpeechResult(TokenType.Number, number, 0, 1));
            }
            return(null);
        }
Exemple #3
0
        public override SpeechResult Process(InputStack command)
        {
            if (command.Count == 0)
            {
                return(null);
            }

            foreach (var alias in Aliases)
            {
                if (command.Peek().Equals(alias, StringComparison.OrdinalIgnoreCase))
                {
                    return(new SpeechResult(TokenType.Text, Word, 0, 1));
                }
            }

            return(null);
        }
Exemple #4
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);
        }
Exemple #5
0
        public override SpeechResult Process(InputStack command)
        {
            if (command.Count == 0)
            {
                return(null);
            }

            SortedSet <SpeechResult> results = new SortedSet <SpeechResult>();

            foreach (var group in EosService.Groups.Values)
            {
                var label      = group.Label;
                var labelParts = label.Split(' ');

                string commandText = "";

                //If there aren't enough tokens, we don't have a match
                if (labelParts.Length > command.Count)
                {
                    continue;
                }

                for (int i = 0; i < labelParts.Length; i++)
                {
                    commandText += " " + command.ToList()[i].ToString();
                }
                commandText = commandText.Trim();
                if (commandText.Equals(label, StringComparison.OrdinalIgnoreCase))
                {
                    results.Add(new SpeechResult(TokenType.Group, group.Number, 100 - labelParts.Length, labelParts.Length));
                }
            }

            if (results.Count > 0)
            {
                return(results.First());
            }
            return(null);
        }
Exemple #6
0
 public virtual SpeechResult Process(InputStack commandStack)
 {
     return(SpeechResult.Empty);
 }