public String toString() { // if we have a feature called 'name' use that // otherwise fall back on the default. String name = getFeatures().getString("name"); if (name == null) { name = ""; } return name; }
private static float getSegmentEnd(Item segment) { FeatureSet segmentFeatureSet = segment.getFeatures(); return segmentFeatureSet.getFloat("end"); }
/** * Adds a break as a feature to the last item in the list. */ public void addBreak() { Item wordItem = (Item) relation.getTail(); if (wordItem != null) { FeatureSet featureSet = wordItem.getFeatures(); featureSet.setString("break", "1"); } }
/** * Sets the last Item in this WordRelation to the given word. * * @param word the word to set */ public void setLastWord(String word) { Item lastItem = relation.getTail(); FeatureSet featureSet = lastItem.getFeatures(); featureSet.setString("name", word); }
/** * 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; }
results = item.getFeatures().getObject(feature);
/** * Convert the given string (which does not only consist of alphabet) into * (word) Items in the WordRelation. * * @param tokenVal the string */ private void notJustAlphasToWords(String tokenVal) { /* its not just alphas */ int index = 0; int tokenLength = tokenVal.length(); for (; index < tokenLength - 1; index++) { if (isTextSplitable(tokenVal, index)) { break; } } if (index == tokenLength - 1) { wordRelation.addWord(tokenVal.toLowerCase()); return; } String aaa = tokenVal.substring(0, index + 1); String bbb = tokenVal.substring(index + 1, tokenLength); FeatureSet featureSet = tokenItem.getFeatures(); featureSet.setString("nsw", "nide"); tokenToWords(aaa); tokenToWords(bbb); }
/** * Adds a word as an Item to this WordRelation object. * * @param word the word to add */ public void addWord(String word) { Item tokenItem = tokenToWords.getTokenItem(); Item wordItem = tokenItem.createDaughter(); FeatureSet featureSet = wordItem.getFeatures(); featureSet.setString("name", word); relation.appendItem(wordItem); }
FeatureSet featureSet = tokenItem.getFeatures();
FeatureSet featureSet = lastItem.getFeatures(); String lastNumber = featureSet.getString("name"); String ordinal = findMatchInArray(lastNumber, digit2num, ord2num);
FeatureSet featureSet = tokenItem.getFeatures(); String punctuation = featureSet.getString("punc");
/** * Convert the given dashed string (e.g. "aaa-bbb") into (word) Items in * the WordRelation. * * @param tokenVal the dashed string */ private void dashToWords(String tokenVal) { int index = tokenVal.indexOf('-'); String aaa = tokenVal.substring(0, index); String bbb = tokenVal.substring(index + 1, tokenVal.length()); if (matches(digitsPattern, aaa) && matches(digitsPattern, bbb)) { FeatureSet featureSet = tokenItem.getFeatures(); featureSet.setString("name", aaa); tokenToWords(aaa); wordRelation.addWord("to"); featureSet.setString("name", bbb); tokenToWords(bbb); featureSet.setString("name", ""); } else { tokenToWords(aaa); tokenToWords(bbb); } }
FeatureSet featureSet = tokenItem.getFeatures(); String nsw = ""; if (featureSet.isPresent("nsw")) {
Item item = relation.appendItem(); FeatureSet featureSet = item.getFeatures(); featureSet.setString("name", tokenWord); featureSet.setString("whitespace", token.getWhitespace());
FeatureSet tokenFeatures = tokenItem.getFeatures(); String itemName = tokenFeatures.getString("name"); int tokenLength = tokenVal.length(); tokenItem.getFeatures().setString("punc", ""); wordRelation.addWord("mister"); } else if (tokenVal.equals("Mrs")) { tokenItem.getFeatures().setString("punc", ""); wordRelation.addWord("missus"); } else if (tokenLength == 1 tokenItem.getFeatures().setString("punc", ",");
tokenItem.getNext()) { FeatureSet featureSet = tokenItem.getFeatures(); String tokenVal = featureSet.getString("name");
public String toString() { // if we have a feature called 'name' use that // otherwise fall back on the default. String name = getFeatures().getString("name"); if (name == null) { name = ""; } return name; }
/** * Sets the last Item in this WordRelation to the given word. * * @param word the word to set */ public void setLastWord(String word) { Item lastItem = relation.getTail(); FeatureSet featureSet = lastItem.getFeatures(); featureSet.setString("name", word); }
/** * Adds a break as a feature to the last item in the list. */ public void addBreak() { Item wordItem = (Item) relation.getTail(); if (wordItem != null) { FeatureSet featureSet = wordItem.getFeatures(); featureSet.setString("break", "1"); } }
/** * Adds a word as an Item to this WordRelation object. * * @param word the word to add */ public void addWord(String word) { Item tokenItem = tokenToWords.getTokenItem(); Item wordItem = tokenItem.createDaughter(); FeatureSet featureSet = wordItem.getFeatures(); featureSet.setString("name", word); relation.appendItem(wordItem); }