/** * Creates a new relation with the given name and adds it to this * utterance. * * @param name the name of the new relation * * @return the newly created relation */ public Relation createRelation(String name) { Relation relation = new Relation(name, this); relations.setObject(name, relation); return relation; }
/** * Adds a new item to this relation. The item added does not share its * contents with any other item. * * @return the newly added item */ public Item appendItem() { return appendItem(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; }
/** * Returns the last item in this WordRelation. * * @return the last item */ public Item getTail() { return relation.getTail(); } }
private static Item findFromFront(Relation segmentRelation, float time) { Item item = segmentRelation.getHead(); while (item != null && time > getSegmentEnd(item)) { item = item.getNext(); } return item; }
/** * Returns the utterance associated with this item. * * @return the utterance that contains this item */ public Utterance getUtterance() { return getOwnerRelation().getUtterance(); }
/** * Creates an item. The item is coupled to a particular Relation. If shared * contents is null a new sharedContents is created. * * @param relation the relation that owns this item * @param sharedContents the contents that is shared with others. If null, * a new sharedContents is created. */ public Item(Relation relation, ItemContents sharedContents) { ownerRelation = relation; if (sharedContents != null) { contents = sharedContents; } else { contents = new ItemContents(); } parent = null; daughter = null; next = null; prev = null; getSharedContents().addItemRelation(relation.getName(), this); }
/** * 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 utterance associated with this item. * * @return the utterance that contains this item */ public Utterance getUtterance() { return getOwnerRelation().getUtterance(); }
/** * Creates an item. The item is coupled to a particular Relation. If shared * contents is null a new sharedContents is created. * * @param relation the relation that owns this item * @param sharedContents the contents that is shared with others. If null, * a new sharedContents is created. */ public Item(Relation relation, ItemContents sharedContents) { ownerRelation = relation; if (sharedContents != null) { contents = sharedContents; } else { contents = new ItemContents(); } parent = null; daughter = null; next = null; prev = null; getSharedContents().addItemRelation(relation.getName(), this); }
/** * 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 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); }
private static Item findFromFront(Relation segmentRelation, float time) { Item item = segmentRelation.getHead(); while (item != null && time > getSegmentEnd(item)) { item = item.getNext(); } return item; }
/** * Creates a new relation with the given name and adds it to this * utterance. * * @param name the name of the new relation * * @return the newly created relation */ public Relation createRelation(String name) { Relation relation = new Relation(name, this); relations.setObject(name, relation); return relation; }
/** * 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"); } }
Item item = relation.appendItem();