/** * Returns true if the given token item contains a token that is in a * section-like context, e.g., "chapter" or "act". * * @param tokenItem the token item to check * * @return true or false */ public static boolean sectionLike(Item tokenItem) { String sectionType = ((String) tokenItem.findFeature("p.name")).toLowerCase(); return inKingSectionLikeMap(sectionType, SECTION_TYPES); }
/** * Returns true if the given token item contains a token that is in a * king-like context, e.g., "King" or "Louis". * * @param tokenItem the token item to check * * @return true or false */ public static boolean kingLike(Item tokenItem) { String kingName = ((String) tokenItem.findFeature("p.name")).toLowerCase(); if (inKingSectionLikeMap(kingName, KING_NAMES)) { return true; } else { String kingTitle = ((String) tokenItem.findFeature("p.p.name")).toLowerCase(); return inKingSectionLikeMap(kingTitle, KING_TITLES); } }
/** * Finds the feature associated with this Path. * * @param item the item to start at * @return the feature associated or "0" if the feature was not found. */ public Object findFeature(Item item) { if (INTERPRET_PATHS) { return item.findFeature(path); } Item pitem = findItem(item); Object results = null; if (pitem != null) { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("findFeature: Item [" + pitem + "], feature '" + feature + "'"); } results = pitem.getFeatures().getObject(feature); } results = (results == null) ? "0" : results; if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("findFeature: ...results = '" + results + "'"); } return results; }
String previous = (String) tokenItem.findFeature("p.name"); String next = (String) tokenItem.findFeature("n.name"); && previous.length() > 2 && matches(alphabetPattern, previous) && tokenItem .findFeature("p.punc").equals(","));
String punctuation = featureSet.getString("punc"); String featPunctuation = (String) tokenItem.findFeature("punc"); wordRelation.addWord(saint); } else { String pName = (String) tokenItem.findFeature("p.name"); String nName = (String) tokenItem.findFeature("n.name"); } else { String whitespace = (String) tokenItem.findFeature("n.whitespace"); if (whitespace.equals(" ")) { wordRelation.addWord(saint);
/** * Returns true if the given token matches part of a phone number * * @param tokenItem the token * @param tokenVal the string value of the token * * @return true or false */ private boolean matchesPartPhoneNumber(String tokenVal) { String n_name = (String) tokenItem.findFeature("n.name"); String n_n_name = (String) tokenItem.findFeature("n.n.name"); String p_name = (String) tokenItem.findFeature("p.name"); String p_p_name = (String) tokenItem.findFeature("p.p.name"); boolean matches3DigitsP_name = matches(threeDigitsPattern, p_name); return ((matches(threeDigitsPattern, tokenVal) && ((!matches( digitsPattern, p_name) && matches(threeDigitsPattern, n_name) && matches( fourDigitsPattern, n_n_name)) || (matches(sevenPhoneNumberPattern, n_name)) || (!matches( digitsPattern, p_p_name) && matches3DigitsP_name && matches( fourDigitsPattern, n_name)))) || (matches( fourDigitsPattern, tokenVal) && (!matches(digitsPattern, n_name) && matches3DigitsP_name && matches(threeDigitsPattern, p_p_name)))); }
if (matches(illionPattern, (String) tokenItem.findFeature("n.name"))) { NumberExpander.expandReal(tokenVal.substring(1), wordRelation); } else if (dotIndex == -1) {
if (matches(digitsPattern, (String) tokenItem.findFeature("p.name")) && tokenItem.getPrevious() != null) { wordRelation.addWord("and");
/** * Converts the given Roman numeral string into (word) Items in the * WordRelation. * * @param romanString the roman numeral string */ private void romanToWords(String romanString) { String punctuation = (String) tokenItem.findFeature("p.punc"); if (punctuation.equals("")) { /* no preceeding punctuation */ String n = String.valueOf(NumberExpander.expandRoman(romanString)); if (kingLike(tokenItem)) { wordRelation.addWord("the"); NumberExpander.expandOrdinal(n, wordRelation); } else if (sectionLike(tokenItem)) { NumberExpander.expandNumber(n, wordRelation); } else { NumberExpander.expandLetters(romanString, wordRelation); } } else { NumberExpander.expandLetters(romanString, wordRelation); } }
&& ((tokenItem.getNext() == null) || !(tokenVal.equals(itemName)) || !(((String) tokenItem .findFeature("punc")).equals("")))) { (String) tokenItem.findFeature("p.name"))) { } else if (tokenLength == 1 && Character.isUpperCase(tokenVal.charAt(0)) && ((String) tokenItem.findFeature("n.whitespace")) .equals(" ") && Character.isUpperCase(((String) tokenItem .findFeature("n.name")).charAt(0))) { String punctuation = (String) tokenItem.findFeature("punc"); if (punctuation.equals("")) { tokenItem.getFeatures().setString("punc", ","); } else if (tokenLength == 1 && Character.isUpperCase(tokenVal.charAt(0)) && ((String) tokenItem.findFeature("n.whitespace")) .equals(" ") && Character.isUpperCase(((String) tokenItem .findFeature("n.name")).charAt(0))) {
/** * Returns true if the given token item contains a token that is in a * section-like context, e.g., "chapter" or "act". * * @param tokenItem the token item to check * * @return true or false */ public static boolean sectionLike(Item tokenItem) { String sectionType = ((String) tokenItem.findFeature("p.name")).toLowerCase(); return inKingSectionLikeMap(sectionType, SECTION_TYPES); }
/** * Returns true if the given token item contains a token that is in a * king-like context, e.g., "King" or "Louis". * * @param tokenItem the token item to check * * @return true or false */ public static boolean kingLike(Item tokenItem) { String kingName = ((String) tokenItem.findFeature("p.name")).toLowerCase(); if (inKingSectionLikeMap(kingName, KING_NAMES)) { return true; } else { String kingTitle = ((String) tokenItem.findFeature("p.p.name")).toLowerCase(); return inKingSectionLikeMap(kingTitle, KING_TITLES); } }
/** * Finds the feature associated with this Path. * * @param item the item to start at * @return the feature associated or "0" if the feature was not found. */ public Object findFeature(Item item) { if (INTERPRET_PATHS) { return item.findFeature(path); } Item pitem = findItem(item); Object results = null; if (pitem != null) { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("findFeature: Item [" + pitem + "], feature '" + feature + "'"); } results = pitem.getFeatures().getObject(feature); } results = (results == null) ? "0" : results; if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("findFeature: ...results = '" + results + "'"); } return results; }
String previous = (String) tokenItem.findFeature("p.name"); String next = (String) tokenItem.findFeature("n.name"); && previous.length() > 2 && matches(alphabetPattern, previous) && tokenItem .findFeature("p.punc").equals(","));
String punctuation = featureSet.getString("punc"); String featPunctuation = (String) tokenItem.findFeature("punc"); wordRelation.addWord(saint); } else { String pName = (String) tokenItem.findFeature("p.name"); String nName = (String) tokenItem.findFeature("n.name"); } else { String whitespace = (String) tokenItem.findFeature("n.whitespace"); if (whitespace.equals(" ")) { wordRelation.addWord(saint);
/** * Returns true if the given token matches part of a phone number * * @param tokenItem the token * @param tokenVal the string value of the token * * @return true or false */ private boolean matchesPartPhoneNumber(String tokenVal) { String n_name = (String) tokenItem.findFeature("n.name"); String n_n_name = (String) tokenItem.findFeature("n.n.name"); String p_name = (String) tokenItem.findFeature("p.name"); String p_p_name = (String) tokenItem.findFeature("p.p.name"); boolean matches3DigitsP_name = matches(threeDigitsPattern, p_name); return ((matches(threeDigitsPattern, tokenVal) && ((!matches( digitsPattern, p_name) && matches(threeDigitsPattern, n_name) && matches( fourDigitsPattern, n_n_name)) || (matches(sevenPhoneNumberPattern, n_name)) || (!matches( digitsPattern, p_p_name) && matches3DigitsP_name && matches( fourDigitsPattern, n_name)))) || (matches( fourDigitsPattern, tokenVal) && (!matches(digitsPattern, n_name) && matches3DigitsP_name && matches(threeDigitsPattern, p_p_name)))); }
if (matches(illionPattern, (String) tokenItem.findFeature("n.name"))) { NumberExpander.expandReal(tokenVal.substring(1), wordRelation); } else if (dotIndex == -1) {
if (matches(digitsPattern, (String) tokenItem.findFeature("p.name")) && tokenItem.getPrevious() != null) { wordRelation.addWord("and");
/** * Converts the given Roman numeral string into (word) Items in the * WordRelation. * * @param romanString the roman numeral string */ private void romanToWords(String romanString) { String punctuation = (String) tokenItem.findFeature("p.punc"); if (punctuation.equals("")) { /* no preceeding punctuation */ String n = String.valueOf(NumberExpander.expandRoman(romanString)); if (kingLike(tokenItem)) { wordRelation.addWord("the"); NumberExpander.expandOrdinal(n, wordRelation); } else if (sectionLike(tokenItem)) { NumberExpander.expandNumber(n, wordRelation); } else { NumberExpander.expandLetters(romanString, wordRelation); } } else { NumberExpander.expandLetters(romanString, wordRelation); } }
&& ((tokenItem.getNext() == null) || !(tokenVal.equals(itemName)) || !(((String) tokenItem .findFeature("punc")).equals("")))) { (String) tokenItem.findFeature("p.name"))) { } else if (tokenLength == 1 && Character.isUpperCase(tokenVal.charAt(0)) && ((String) tokenItem.findFeature("n.whitespace")) .equals(" ") && Character.isUpperCase(((String) tokenItem .findFeature("n.name")).charAt(0))) { String punctuation = (String) tokenItem.findFeature("punc"); if (punctuation.equals("")) { tokenItem.getFeatures().setString("punc", ","); } else if (tokenLength == 1 && Character.isUpperCase(tokenVal.charAt(0)) && ((String) tokenItem.findFeature("n.whitespace")) .equals(" ") && Character.isUpperCase(((String) tokenItem .findFeature("n.name")).charAt(0))) {