Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
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')]);
     }
 }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
     }
 }
Ejemplo n.º 5
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");
                }
            }
        }
Ejemplo n.º 6
0
        public static void expandOrdinal(string rawNumberString, WordRelation wordRelation)
        {
            object       obj           = ",";
            object       obj2          = "";
            object       _ref          = obj;
            CharSequence charSequence  = CharSequence.Cast(_ref);
            CharSequence charSequence2 = charSequence;

            _ref         = obj2;
            charSequence = CharSequence.Cast(_ref);
            NumberExpander.expandNumber(String.instancehelper_replace(rawNumberString, charSequence2, charSequence), wordRelation);
            Item tail = wordRelation.getTail();

            if (tail != null)
            {
                FeatureSet features = tail.getFeatures();
                string     @string  = features.getString("name");
                string     text     = NumberExpander.findMatchInArray(@string, NumberExpander.digit2num, NumberExpander.ord2num);
                if (text == null)
                {
                    text = NumberExpander.findMatchInArray(@string, NumberExpander.digit2teen, NumberExpander.ord2teen);
                }
                if (text == null)
                {
                    text = NumberExpander.findMatchInArray(@string, NumberExpander.digit2enty, NumberExpander.ord2enty);
                }
                if (String.instancehelper_equals(@string, "hundred"))
                {
                    text = "hundredth";
                }
                else if (String.instancehelper_equals(@string, "thousand"))
                {
                    text = "thousandth";
                }
                else if (String.instancehelper_equals(@string, "billion"))
                {
                    text = "billionth";
                }
                if (text != null)
                {
                    wordRelation.setLastWord(text);
                }
            }
        }
Ejemplo n.º 7
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);
                }
            }
        }
Ejemplo n.º 8
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));
         }
     }
 }
Ejemplo n.º 9
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);
            }
        }
Ejemplo n.º 10
0
        public static void expandNumber(string numberString, WordRelation wordRelation)
        {
            int num = String.instancehelper_length(numberString);

            if (num != 0)
            {
                if (num == 1)
                {
                    NumberExpander.expandDigits(numberString, wordRelation);
                }
                else if (num == 2)
                {
                    NumberExpander.expand2DigitNumber(numberString, wordRelation);
                }
                else if (num == 3)
                {
                    NumberExpander.expand3DigitNumber(numberString, wordRelation);
                }
                else if (num < 7)
                {
                    NumberExpander.expandBelow7DigitNumber(numberString, wordRelation);
                }
                else if (num < 10)
                {
                    NumberExpander.expandBelow10DigitNumber(numberString, wordRelation);
                }
                else if (num < 13)
                {
                    NumberExpander.expandBelow13DigitNumber(numberString, wordRelation);
                }
                else
                {
                    NumberExpander.expandDigits(numberString, wordRelation);
                }
            }
        }
Ejemplo n.º 11
0
 private static void expandNumberAt(string text, int num, WordRelation wordRelation)
 {
     NumberExpander.expandNumber(String.instancehelper_substring(text, num, String.instancehelper_length(text)), wordRelation);
 }
Ejemplo n.º 12
0
 private static void expandBelow13DigitNumber(string text, WordRelation wordRelation)
 {
     NumberExpander.expandLargeNumber(text, "billion", 9, wordRelation);
 }
Ejemplo n.º 13
0
 private static void expandBelow7DigitNumber(string text, WordRelation wordRelation)
 {
     NumberExpander.expandLargeNumber(text, "thousand", 3, wordRelation);
 }