private void digitsSlashDigitsToWords(string text) { int num = String.instancehelper_indexOf(text, 47); string text2 = String.instancehelper_substring(text, 0, num); string text3 = String.instancehelper_substring(text, num + 1); if (USEnglishTokenizer.matches(USEnglishTokenizer.digitsPattern, (string)this.tokenItem.findFeature("p.name")) && this.tokenItem.getPrevious() != null) { this.wordRelation.addWord("and"); } int num2; if (String.instancehelper_equals(text2, "1") && String.instancehelper_equals(text3, "2")) { this.wordRelation.addWord("a"); this.wordRelation.addWord("half"); } else if ((num2 = Integer.parseInt(text2)) < Integer.parseInt(text3)) { NumberExpander.expandNumber(text2, this.wordRelation); NumberExpander.expandOrdinal(text3, this.wordRelation); if (num2 > 1) { this.wordRelation.addWord("'s"); } } else { NumberExpander.expandNumber(text2, this.wordRelation); this.wordRelation.addWord("slash"); NumberExpander.expandNumber(text3, this.wordRelation); } }
private void usMoneyToWords(string text) { int num = String.instancehelper_indexOf(text, 46); if (USEnglishTokenizer.matches(USEnglishTokenizer.illionPattern, (string)this.tokenItem.findFeature("n.name"))) { NumberExpander.expandReal(String.instancehelper_substring(text, 1), this.wordRelation); } else if (num == -1) { string text2 = String.instancehelper_substring(text, 1); this.tokenToWords(text2); if (String.instancehelper_equals(text2, "1")) { this.wordRelation.addWord("dollar"); } else { this.wordRelation.addWord("dollars"); } } else if (num == String.instancehelper_length(text) - 1 || String.instancehelper_length(text) - num > 3) { NumberExpander.expandReal(String.instancehelper_substring(text, 1), this.wordRelation); this.wordRelation.addWord("dollars"); } else { string text3 = String.instancehelper_substring(text, 1, num); object obj = ","; object obj2 = ""; CharSequence charSequence = CharSequence.Cast(obj); CharSequence charSequence2 = CharSequence.Cast(obj2); string text2 = String.instancehelper_replace(text3, charSequence2, charSequence); string text4 = String.instancehelper_substring(text, num + 1); NumberExpander.expandNumber(text2, this.wordRelation); if (String.instancehelper_equals(text2, "1")) { this.wordRelation.addWord("dollar"); } else { this.wordRelation.addWord("dollars"); } if (!String.instancehelper_equals(text4, "00")) { NumberExpander.expandNumber(text4, this.wordRelation); if (String.instancehelper_equals(text4, "01")) { this.wordRelation.addWord("cent"); } else { this.wordRelation.addWord("cents"); } } } }
private bool matchesPartPhoneNumber(string text) { string text2 = (string)this.tokenItem.findFeature("n.name"); string text3 = (string)this.tokenItem.findFeature("n.n.name"); string text4 = (string)this.tokenItem.findFeature("p.name"); string text5 = (string)this.tokenItem.findFeature("p.p.name"); int num = USEnglishTokenizer.matches(USEnglishTokenizer.threeDigitsPattern, text4) ? 1 : 0; return((USEnglishTokenizer.matches(USEnglishTokenizer.threeDigitsPattern, text) && ((!USEnglishTokenizer.matches(USEnglishTokenizer.digitsPattern, text4) && USEnglishTokenizer.matches(USEnglishTokenizer.threeDigitsPattern, text2) && USEnglishTokenizer.matches(USEnglishTokenizer.fourDigitsPattern, text3)) || USEnglishTokenizer.matches(USEnglishTokenizer.sevenPhoneNumberPattern, text2) || (!USEnglishTokenizer.matches(USEnglishTokenizer.digitsPattern, text5) && num != 0 && USEnglishTokenizer.matches(USEnglishTokenizer.fourDigitsPattern, text2)))) || (USEnglishTokenizer.matches(USEnglishTokenizer.fourDigitsPattern, text) && !USEnglishTokenizer.matches(USEnglishTokenizer.digitsPattern, text2) && num != 0 && USEnglishTokenizer.matches(USEnglishTokenizer.threeDigitsPattern, text5))); }
private void dashToWords(string text) { int num = String.instancehelper_indexOf(text, 45); string text2 = String.instancehelper_substring(text, 0, num); string text3 = String.instancehelper_substring(text, num + 1, String.instancehelper_length(text)); if (USEnglishTokenizer.matches(USEnglishTokenizer.digitsPattern, text2) && USEnglishTokenizer.matches(USEnglishTokenizer.digitsPattern, text3)) { FeatureSet features = this.tokenItem.getFeatures(); features.setString("name", text2); this.tokenToWords(text2); this.wordRelation.addWord("to"); features.setString("name", text3); this.tokenToWords(text3); features.setString("name", ""); } else { this.tokenToWords(text2); this.tokenToWords(text3); } }
private bool isStateName(string text) { string[] array = (string[])((string[])USEnglishTokenizer.usStatesMap.get(text)); if (array != null) { int num4; if (String.instancehelper_equals(array[1], "ambiguous")) { string text2 = (string)this.tokenItem.findFeature("p.name"); string text3 = (string)this.tokenItem.findFeature("n.name"); int num = String.instancehelper_length(text3); FeatureSet features = this.tokenItem.getFeatures(); int num2 = (!Character.isUpperCase(String.instancehelper_charAt(text2, 0)) || String.instancehelper_length(text2) <= 2 || !USEnglishTokenizer.matches(USEnglishTokenizer.alphabetPattern, text2) || !Object.instancehelper_equals(this.tokenItem.findFeature("p.punc"), ",")) ? 0 : 1; int num3 = (!Character.isLowerCase(String.instancehelper_charAt(text3, 0)) && this.tokenItem.getNext() != null && !String.instancehelper_equals(features.getString("punc"), ".") && ((num != 5 && num != 10) || !USEnglishTokenizer.matches(USEnglishTokenizer.digitsPattern, text3))) ? 0 : 1; if (num2 != 0 && num3 != 0) { num4 = 1; } else { num4 = 0; } } else { num4 = 1; } if (num4 != 0) { for (int i = 2; i < array.Length; i++) { if (array[i] != null) { this.wordRelation.addWord(array[i]); } } return(true); } } return(false); }
private void tokenToWords(string text) { FeatureSet features = this.tokenItem.getFeatures(); string @string = features.getString("name"); int num = String.instancehelper_length(text); if (features.isPresent("phones")) { this.wordRelation.addWord(text); } else if ((String.instancehelper_equals(text, "a") || String.instancehelper_equals(text, "A")) && (this.tokenItem.getNext() == null || !String.instancehelper_equals(text, @string) || !String.instancehelper_equals((string)this.tokenItem.findFeature("punc"), ""))) { this.wordRelation.addWord("_a"); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.alphabetPattern, text)) { if (USEnglishTokenizer.matches(USEnglishTokenizer.romanNumbersPattern, text)) { this.romanToWords(text); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.illionPattern, text) && USEnglishTokenizer.matches(USEnglishTokenizer.usMoneyPattern, (string)this.tokenItem.findFeature("p.name"))) { this.wordRelation.addWord(text); this.wordRelation.addWord("dollars"); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.drStPattern, text)) { this.drStToWords(text); } else if (String.instancehelper_equals(text, "Mr")) { this.tokenItem.getFeatures().setString("punc", ""); this.wordRelation.addWord("mister"); } else if (String.instancehelper_equals(text, "Mrs")) { this.tokenItem.getFeatures().setString("punc", ""); this.wordRelation.addWord("missus"); } else if (num == 1 && Character.isUpperCase(String.instancehelper_charAt(text, 0)) && String.instancehelper_equals((string)this.tokenItem.findFeature("n.whitespace"), " ") && Character.isUpperCase(String.instancehelper_charAt((string)this.tokenItem.findFeature("n.name"), 0))) { features.setString("punc", ""); string text2 = String.instancehelper_toLowerCase(text); if (String.instancehelper_equals(text2, "a")) { this.wordRelation.addWord("_a"); } else { this.wordRelation.addWord(text2); } } else if (!this.isStateName(text)) { if (num > 1 && !this.isPronounceable(text)) { NumberExpander.expandLetters(text, this.wordRelation); } else { this.wordRelation.addWord(String.instancehelper_toLowerCase(text)); } } } else if (USEnglishTokenizer.matches(USEnglishTokenizer.dottedAbbrevPattern, text)) { object obj = "."; object obj2 = ""; CharSequence charSequence = CharSequence.Cast(obj); CharSequence charSequence2 = CharSequence.Cast(obj2); NumberExpander.expandLetters(String.instancehelper_replace(text, charSequence2, charSequence), this.wordRelation); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.commaIntPattern, text)) { object obj4 = ","; object obj3 = ""; object obj2 = obj4; CharSequence charSequence = CharSequence.Cast(obj4); CharSequence charSequence3 = CharSequence.Cast(obj3); string text3 = String.instancehelper_replace(text, charSequence3, charSequence); object obj5 = "'"; obj2 = ""; charSequence = CharSequence.Cast(obj5); CharSequence charSequence4 = charSequence; charSequence = CharSequence.Cast(obj2); NumberExpander.expandReal(String.instancehelper_replace(text3, charSequence4, charSequence), this.wordRelation); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.sevenPhoneNumberPattern, text)) { int num2 = String.instancehelper_indexOf(text, 45); string numberString = String.instancehelper_substring(text, 0, num2); string text4 = String.instancehelper_substring(text, num2 + 1); NumberExpander.expandDigits(numberString, this.wordRelation); this.wordRelation.addBreak(); NumberExpander.expandDigits(text4, this.wordRelation); } else if (this.matchesPartPhoneNumber(text)) { string text2 = (string)this.tokenItem.findFeature("punc"); if (String.instancehelper_equals(text2, "")) { this.tokenItem.getFeatures().setString("punc", ","); } NumberExpander.expandDigits(text, this.wordRelation); this.wordRelation.addBreak(); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.numberTimePattern, text)) { int num2 = String.instancehelper_indexOf(text, 58); string numberString = String.instancehelper_substring(text, 0, num2); string text4 = String.instancehelper_substring(text, num2 + 1); NumberExpander.expandNumber(numberString, this.wordRelation); if (!String.instancehelper_equals(text4, "00")) { NumberExpander.expandID(text4, this.wordRelation); } } else if (USEnglishTokenizer.matches(USEnglishTokenizer.digits2DashPattern, text)) { this.digitsDashToWords(text); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.digitsPattern, text)) { this.digitsToWords(text); } else if (num == 1 && Character.isUpperCase(String.instancehelper_charAt(text, 0)) && String.instancehelper_equals((string)this.tokenItem.findFeature("n.whitespace"), " ") && Character.isUpperCase(String.instancehelper_charAt((string)this.tokenItem.findFeature("n.name"), 0))) { features.setString("punc", ""); string text2 = String.instancehelper_toLowerCase(text); if (String.instancehelper_equals(text2, "a")) { this.wordRelation.addWord("_a"); } else { this.wordRelation.addWord(text2); } } else if (USEnglishTokenizer.matches(USEnglishTokenizer.doublePattern, text)) { NumberExpander.expandReal(text, this.wordRelation); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.ordinalPattern, text)) { string text2 = String.instancehelper_substring(text, 0, num - 2); NumberExpander.expandOrdinal(text2, this.wordRelation); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.usMoneyPattern, text)) { this.usMoneyToWords(text); } else if (num > 0 && String.instancehelper_charAt(text, num - 1) == '%') { this.tokenToWords(String.instancehelper_substring(text, 0, num - 1)); this.wordRelation.addWord("percent"); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.numessPattern, text)) { NumberExpander.expandNumess(String.instancehelper_substring(text, 0, num - 1), this.wordRelation); } else if (USEnglishTokenizer.matches(USEnglishTokenizer.digitsSlashDigitsPattern, text) && String.instancehelper_equals(text, @string)) { this.digitsSlashDigitsToWords(text); } else if (String.instancehelper_indexOf(text, 45) != -1) { this.dashToWords(text); } else if (num > 1 && !USEnglishTokenizer.matches(USEnglishTokenizer.alphabetPattern, text)) { this.notJustAlphasToWords(text); } else if (String.instancehelper_equals(text, "&")) { this.wordRelation.addWord("and"); } else if (!String.instancehelper_equals(text, "-")) { this.wordRelation.addWord(String.instancehelper_toLowerCase(text)); } }