Example #1
0
 private static void expand2DigitNumber(string text, WordRelation wordRelation)
 {
     if (String.instancehelper_charAt(text, 0) == '0')
     {
         if (String.instancehelper_charAt(text, 1) != '0')
         {
             string word = NumberExpander.digit2num[(int)(String.instancehelper_charAt(text, 1) - '0')];
             wordRelation.addWord(word);
         }
     }
     else if (String.instancehelper_charAt(text, 1) == '0')
     {
         string word = NumberExpander.digit2enty[(int)(String.instancehelper_charAt(text, 0) - '0')];
         wordRelation.addWord(word);
     }
     else if (String.instancehelper_charAt(text, 0) == '1')
     {
         string word = NumberExpander.digit2teen[(int)(String.instancehelper_charAt(text, 1) - '0')];
         wordRelation.addWord(word);
     }
     else
     {
         string word = NumberExpander.digit2enty[(int)(String.instancehelper_charAt(text, 0) - '0')];
         wordRelation.addWord(word);
         NumberExpander.expandDigits(String.instancehelper_substring(text, 1, String.instancehelper_length(text)), wordRelation);
     }
 }
Example #2
0
 private static void expand3DigitNumber(string text, WordRelation wordRelation)
 {
     if (String.instancehelper_charAt(text, 0) == '0')
     {
         NumberExpander.expandNumberAt(text, 1, wordRelation);
     }
     else
     {
         string word = NumberExpander.digit2num[(int)(String.instancehelper_charAt(text, 0) - '0')];
         wordRelation.addWord(word);
         wordRelation.addWord("hundred");
         NumberExpander.expandNumberAt(text, 1, wordRelation);
     }
 }
Example #3
0
        public static void expandDigits(string numberString, WordRelation wordRelation)
        {
            int num = String.instancehelper_length(numberString);

            for (int i = 0; i < num; i++)
            {
                int num2 = (int)String.instancehelper_charAt(numberString, i);
                if (Character.isDigit((char)num2))
                {
                    wordRelation.addWord(NumberExpander.digit2num[(int)(String.instancehelper_charAt(numberString, i) - '0')]);
                }
                else
                {
                    wordRelation.addWord("umpty");
                }
            }
        }
Example #4
0
        public static void expandID(string numberString, WordRelation wordRelation)
        {
            int num = String.instancehelper_length(numberString);

            if (num == 4 && String.instancehelper_charAt(numberString, 2) == '0' && String.instancehelper_charAt(numberString, 3) == '0')
            {
                if (String.instancehelper_charAt(numberString, 1) == '0')
                {
                    NumberExpander.expandNumber(numberString, wordRelation);
                }
                else
                {
                    NumberExpander.expandNumber(String.instancehelper_substring(numberString, 0, 2), wordRelation);
                    wordRelation.addWord("hundred");
                }
            }
            else if (num == 2 && String.instancehelper_charAt(numberString, 0) == '0')
            {
                wordRelation.addWord("oh");
                NumberExpander.expandDigits(String.instancehelper_substring(numberString, 1, 2), wordRelation);
            }
            else if ((num == 4 && String.instancehelper_charAt(numberString, 1) == '0') || num < 3)
            {
                NumberExpander.expandNumber(numberString, wordRelation);
            }
            else
            {
                int num2 = num;
                int num3 = 2;
                if (((num3 != -1) ? (num2 % num3) : 0) == 1)
                {
                    string word = NumberExpander.digit2num[(int)(String.instancehelper_charAt(numberString, 0) - '0')];
                    wordRelation.addWord(word);
                    NumberExpander.expandID(String.instancehelper_substring(numberString, 1, num), wordRelation);
                }
                else
                {
                    NumberExpander.expandNumber(String.instancehelper_substring(numberString, 0, 2), wordRelation);
                    NumberExpander.expandID(String.instancehelper_substring(numberString, 2, num), wordRelation);
                }
            }
        }
Example #5
0
 public static void expandLetters(string letters, WordRelation wordRelation)
 {
     letters = String.instancehelper_toLowerCase(letters);
     for (int i = 0; i < String.instancehelper_length(letters); i++)
     {
         int num = (int)String.instancehelper_charAt(letters, i);
         if (Character.isDigit((char)num))
         {
             wordRelation.addWord(NumberExpander.digit2num[num - 48]);
         }
         else if (String.instancehelper_equals(letters, "a"))
         {
             wordRelation.addWord("_a");
         }
         else
         {
             wordRelation.addWord(String.valueOf((char)num));
         }
     }
 }
Example #6
0
 public static void expandNumess(string rawString, WordRelation wordRelation)
 {
     if (String.instancehelper_length(rawString) == 4)
     {
         NumberExpander.expand2DigitNumber(String.instancehelper_substring(rawString, 0, 2), wordRelation);
         NumberExpander.expandNumess(String.instancehelper_substring(rawString, 2), wordRelation);
     }
     else
     {
         wordRelation.addWord(NumberExpander.digit2Numness[(int)(String.instancehelper_charAt(rawString, 0) - '0')]);
     }
 }
Example #7
0
        public static void expandReal(string numberString, WordRelation wordRelation)
        {
            int num = String.instancehelper_length(numberString);
            int num2;

            if (String.instancehelper_charAt(numberString, 0) == '-')
            {
                wordRelation.addWord("minus");
                NumberExpander.expandReal(String.instancehelper_substring(numberString, 1, num), wordRelation);
            }
            else if (String.instancehelper_charAt(numberString, 0) == '+')
            {
                wordRelation.addWord("plus");
                NumberExpander.expandReal(String.instancehelper_substring(numberString, 1, num), wordRelation);
            }
            else if ((num2 = String.instancehelper_indexOf(numberString, 101)) != -1 || (num2 = String.instancehelper_indexOf(numberString, 69)) != -1)
            {
                NumberExpander.expandReal(String.instancehelper_substring(numberString, 0, num2), wordRelation);
                wordRelation.addWord("e");
                NumberExpander.expandReal(String.instancehelper_substring(numberString, num2 + 1), wordRelation);
            }
            else if ((num2 = String.instancehelper_indexOf(numberString, 46)) != -1)
            {
                string text = String.instancehelper_substring(numberString, 0, num2);
                if (String.instancehelper_length(text) > 0)
                {
                    NumberExpander.expandReal(text, wordRelation);
                }
                wordRelation.addWord("point");
                string text2 = String.instancehelper_substring(numberString, num2 + 1);
                if (String.instancehelper_length(text2) > 0)
                {
                    NumberExpander.expandDigits(text2, wordRelation);
                }
            }
            else
            {
                NumberExpander.expandNumber(numberString, wordRelation);
            }
        }
Example #8
0
        private static void expandLargeNumber(string text, string word, int num, WordRelation wordRelation)
        {
            int    num2         = String.instancehelper_length(text);
            int    num3         = num2 - num;
            string numberString = String.instancehelper_substring(text, 0, num3);
            Item   tail         = wordRelation.getTail();

            NumberExpander.expandNumber(numberString, wordRelation);
            if (wordRelation.getTail() != tail)
            {
                wordRelation.addWord(word);
            }
            NumberExpander.expandNumberAt(text, num3, wordRelation);
        }