private static void expandLargeNumber(string numberString, string order, int numberZeroes, WordRelation wordRelation) { int numberDigits = numberString.Length; // parse out the prefix, e.g., "113" in "113,000" int i = numberDigits - numberZeroes; string part = numberString.Substring(0, i); // get how many thousands/millions/billions Item oldTail = wordRelation.getTail(); expandNumber(part, wordRelation); if (wordRelation.getTail() != oldTail) { wordRelation.addWord(order); } expandNumberAt(numberString, i, wordRelation); }
public static void expandOrdinal(string rawNumberString, WordRelation wordRelation) { expandNumber(rawNumberString.Replace(",", ""), wordRelation); // get the last in the list of number strings Item lastItem = wordRelation.getTail(); if (lastItem != null) { FeatureSet featureSet = lastItem.getFeatures(); string lastNumber = featureSet.getString("name"); string ordinal = findMatchInArray(lastNumber, digit2num, ord2num); if (ordinal == null) { ordinal = findMatchInArray(lastNumber, digit2teen, ord2teen); } if (ordinal == null) { ordinal = findMatchInArray(lastNumber, digit2enty, ord2enty); } if (lastNumber.Equals("hundred")) { ordinal = "hundredth"; } else if (lastNumber.Equals("thousand")) { ordinal = "thousandth"; } else if (lastNumber.Equals("billion")) { ordinal = "billionth"; } // if there was an ordinal, set the last element of the list // to that ordinal; otherwise, don't do anything if (ordinal != null) { wordRelation.setLastWord(ordinal); } } }