Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
0
 private static void expandNumberAt(string text, int num, WordRelation wordRelation)
 {
     NumberExpander.expandNumber(String.instancehelper_substring(text, num, String.instancehelper_length(text)), wordRelation);
 }