/** * Adds the given item as a daughter to this item. * * @param item for the new daughter * @return created item */ public Item addDaughter(Item item) { Item newItem; ItemContents contents; Item p = getLastDaughter(); if (p != null) { newItem = p.appendItem(item); } else { if (item == null) { contents = new ItemContents(); } else { contents = item.getSharedContents(); } newItem = new Item(getOwnerRelation(), contents); newItem.parent = this; daughter = newItem; } return newItem; }
/** * Creates a new Item, adds it as a daughter to this item and returns the * new item. * * @return the newly created item that was added as a daughter */ public Item createDaughter() { return addDaughter(null); }
/** * Appends an item in this list after this item. * * @param originalItem new item has shared contents with this item (or * * null) * * @return the newly appended item */ public Item appendItem(Item originalItem) { ItemContents contents; Item newItem; if (originalItem == null) { contents = null; } else { contents = originalItem.getSharedContents(); } newItem = new Item(getOwnerRelation(), contents); newItem.next = this.next; if (this.next != null) { this.next.prev = newItem; } attach(newItem); if (this.ownerRelation.getTail() == this) { this.ownerRelation.setTail(newItem); } return newItem; }
/** * Adds a new item to this relation. The item added shares its contents * with the original item. * * @param originalItem the ItemContents that will be shared by the new item * * @return the newly added item */ public Item appendItem(Item originalItem) { ItemContents contents; Item newItem; if (originalItem == null) { contents = null; } else { contents = originalItem.getSharedContents(); } newItem = new Item(this, contents); if (head == null) { head = newItem; } if (tail != null) { tail.attach(newItem); } tail = newItem; return newItem; }
return item.findItem(path); OpEnum op = (OpEnum) compiledPath[i++]; if (op == OpEnum.NEXT) { pitem = pitem.getNext(); } else if (op == OpEnum.PREV) { pitem = pitem.getPrevious(); } else if (op == OpEnum.NEXT_NEXT) { pitem = pitem.getNext(); if (pitem != null) { pitem = pitem.getNext(); pitem = pitem.getPrevious(); if (pitem != null) { pitem = pitem.getPrevious(); pitem = pitem.getParent(); } else if (op == OpEnum.DAUGHTER) { pitem = pitem.getDaughter(); } else if (op == OpEnum.LAST_DAUGHTER) { pitem = pitem.getLastDaughter(); } else if (op == OpEnum.RELATION) { String relationName = (String) compiledPath[i++]; pitem = pitem.getSharedContents() .getItemRelation(relationName); } else {
String previous = (String) tokenItem.findFeature("p.name"); String next = (String) tokenItem.findFeature("n.name"); FeatureSet featureSet = tokenItem.getFeatures(); && previous.length() > 2 && matches(alphabetPattern, previous) && tokenItem .findFeature("p.punc").equals(",")); || tokenItem.getNext() == null || featureSet.getString("punc").equals(".") || ((nextLength == 5 || nextLength == 10) && matches( digitsPattern, next)));
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; }
contents = null; } else { contents = originalItem.getSharedContents(); newItem = new Item(getOwnerRelation(), contents); newItem.prev = this.prev; if (this.prev != null) {
/** * 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); }
/** * 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); }
/** * 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; }
if (matches(digitsPattern, (String) tokenItem.findFeature("p.name")) && tokenItem.getPrevious() != null) { wordRelation.addWord("and");
item = findItem(path); if (item != null) { results = item.getFeatures().getObject(feature);
String token = tok.nextToken(); if (token.equals("n")) { pitem = pitem.getNext(); } else if (token.equals("p")) { pitem = pitem.getPrevious(); } else if (token.equals("nn")) { pitem = pitem.getNext(); if (pitem != null) { pitem = pitem.getNext(); pitem = pitem.getPrevious(); if (pitem != null) { pitem = pitem.getPrevious(); pitem = pitem.getParent(); } else if (token.equals("daughter") || token.equals("daughter1")) { pitem = pitem.getDaughter(); } else if (token.equals("daughtern")) { pitem = pitem.getLastDaughter(); } else if (token.equals("R")) { String relationName = tok.nextToken(); pitem = pitem.getSharedContents() .getItemRelation(relationName); } else {
FeatureSet featureSet = tokenItem.getFeatures(); String punctuation = featureSet.getString("punc"); String featPunctuation = (String) tokenItem.findFeature("punc"); if (tokenItem.getNext() == null || punctuation.indexOf(',') != -1) { wordRelation.addWord(street); } else if (featPunctuation.equals(",")) { 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);
private static float getSegmentEnd(Item segment) { FeatureSet segmentFeatureSet = segment.getFeatures(); return segmentFeatureSet.getFloat("end"); }
/** * Adds a new item to this relation. The item added shares its contents * with the original item. * * @param originalItem the ItemContents that will be shared by the new item * * @return the newly added item */ public Item appendItem(Item originalItem) { ItemContents contents; Item newItem; if (originalItem == null) { contents = null; } else { contents = originalItem.getSharedContents(); } newItem = new Item(this, contents); if (head == null) { head = newItem; } if (tail != null) { tail.attach(newItem); } tail = newItem; return newItem; }
contents = null; } else { contents = originalItem.getSharedContents(); newItem = new Item(getOwnerRelation(), contents); newItem.prev = this.prev; if (this.prev != null) {