Ejemplo n.º 1
0
        public static string ToText(this int num)
        {
            var numberText = new NumberText();

            return(numberText.ToText(num));
        }
Ejemplo n.º 2
0
        private GrammarBuilder CreateGrammar()
        {
            NumberText numbers = new NumberText();


            //The calculator build
            GrammarBuilder[] gb = new GrammarBuilder[5] {
                null, null, null, null, null
            };
            gb[0] = new GrammarBuilder(new Choices("exit"));
            gb[1] = new GrammarBuilder();
            gb[2] = new GrammarBuilder();
            gb[3] = new GrammarBuilder();
            //MAking choices for the different things that could be said for calling one array
            Choices man = new Choices();

            man.Add(new string[] { "Botch can you tell the class how much is", "What is" });
            gb[3].Append(man); //to pass the speech said
            string[] numberString = { "zero",    "one",       "two",      "three",    "four",
                                      "five",    "six",       "seven",    "eight",    "nine",   "ten",
                                      "eleven",  "twelve",    "thirteen", "fourteen", "fifteen",
                                      "sixteen", "seventeen", "eighteen", "nineteen", "twenty" };

            //numbers.ToText();

            //This is where the numbers are assigned to their semantic values
            Choices numberChoices = new Choices();

            for (int i = 0; i < numberString.Length; i++)
            {
                numberChoices.Add(new SemanticResultValue(numberString[i], i));
            }
            //first number appended before the operator
            gb[3].Append(new SemanticResultKey("number1", (GrammarBuilder)numberChoices));
            string[] operatorString  = { "plus", "and", "minus", "times", "divided by", "squared", "factorial" };
            Choices  operatorChoices = new Choices();

            operatorChoices.Add(new SemanticResultValue("plus", "+"));
            operatorChoices.Add(new SemanticResultValue("and", "+"));
            operatorChoices.Add(new SemanticResultValue("minus", "-"));
            operatorChoices.Add(new SemanticResultValue("times", "*"));
            operatorChoices.Add(new SemanticResultValue("multiplied by", "*"));
            operatorChoices.Add(new SemanticResultValue("divided by", "/"));
            operatorChoices.Add(new SemanticResultValue("to the power of", "^"));
            operatorChoices.Add(new SemanticResultValue("squared", "X^x"));
            //operatorChoices.Add(new SemanticResultValue("factorial", "!"));

            //the factorial grammer
            Choices factorialSpeech = new Choices();

            factorialSpeech.Add(new string[] { "calculate" });
            gb[2].Append(factorialSpeech);
            Choices factorial = new Choices();

            factorial.Add(new SemanticResultValue("factorial", "!"));
            gb[2].Append(new SemanticResultKey("numberf", (GrammarBuilder)numberChoices));


            //The intro build// i had to create a new instance for the new subscript match it with a new chice which is intro
            gb[4] = new GrammarBuilder();
            Choices intro = new Choices();

            intro.Add(new string[] { "Intoduce yourself", "Botch", "How are you today, botch. I know we wroked late yesterday!", "Hi" });



            //This is how all of the values are returned through the array.
            //our error for today is here under this damn line !!!!!!!!!!!!!!!!! irony factorial uses the same symb9ol
            gb[2].Append(new SemanticResultKey("factorial", (GrammarBuilder)factorial));
            gb[3].Append(new SemanticResultKey("operator", (GrammarBuilder)operatorChoices));
            //second number appended after the operator
            gb[3].Append(new SemanticResultKey("number2", (GrammarBuilder)numberChoices));
            gb[4].Append(intro);



            //The returning of the whole array
            Choices choices = new Choices(gb);

            return(new GrammarBuilder(choices));
        }