/** * Returns the last item in this WordRelation. * * @return the last item */ public Item getTail() { return relation.getTail(); } }
/** * 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"); } }
private static Item getItem(Relation segmentRelation, float time) { Item lastSegment = segmentRelation.getTail(); // If given time is closer to the front than the end, search from // the front; otherwise, start search from end // this might not be the best strategy though. float lastSegmentEndTime = getSegmentEnd(lastSegment); if (time < 0 || lastSegmentEndTime < time) { return null; } else if (lastSegmentEndTime - time > time) { return findFromFront(segmentRelation, time); } else { return findFromEnd(segmentRelation, time); } }
/** * 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; }
/** * Returns the last item in this WordRelation. * * @return the last item */ public Item getTail() { return relation.getTail(); } }
/** * 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); }
private static Item getItem(Relation segmentRelation, float time) { Item lastSegment = segmentRelation.getTail(); // If given time is closer to the front than the end, search from // the front; otherwise, start search from end // this might not be the best strategy though. float lastSegmentEndTime = getSegmentEnd(lastSegment); if (time < 0 || lastSegmentEndTime < time) { return null; } else if (lastSegmentEndTime - time > time) { return findFromFront(segmentRelation, time); } else { return findFromEnd(segmentRelation, time); } }
/** * 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; }