Package nzilbb.labbcat.server.db
Class IdUtterance
- java.lang.Object
-
- nzilbb.labbcat.server.db.IdUtterance
-
- Direct Known Subclasses:
IdMatch
public class IdUtterance extends Object
Serializer/deserializer for a string-encoded identifier for a single utterance.To make scripting and a number of other things easier, we need a schema for identifying a graph fragment with a single string identifier.
Some combination of
- graph ID (integer)
- start anchor ID (long integer)
- end anchor ID (long integer)
- speaker number (integer)
- defining annotation UID (string)
...can be used to construct a graph fragment that starts and ends at particular anchors and maybe filters out annotations that belong to other speakers. Strictly speaking the graph ID is redundant, as an anchor ID or annotation UID can be used to identify the graph (but having it is convenient).
Being able to recover the fragment from anchor offsets would be useful too.
It is also handy to be able to append optional extra info to the ID, e.g.
- prefix/result number
- maybe search name
- pointers into the fragment, e.g. the match word, or ideally, a range or list of match annotations, for search results.
It should be short, and it should be possible to reconstruct a working URL from the ID.
The schema is:
-
when there's a defining annotation UID:
g_ag_id;uid
e.g. g_243;em_12_20035 -
when there's anchor IDs:
g_ag_id;startuid-enduid
e.g. g_243;n_72700-n_72709 -
when there's anchor offsets:
g_ag_id;startoffset-endoffset
e.g. g_243;39.400-46.279 -
when there's a participant/speaker number, it will be appended:
...;p_speakernumber
e.g. g_243;n_72700-n_72709;p_76 -
other items (search name or prefix) could then come after all that, and
key=value pairs:
...;key=value
e.g. g_243;n_72700-n_72709;ew_0_123-ew_0_234;prefix=024-;name=the_aeiou
- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Constructor Summary
Constructors Constructor Description IdUtterance()
Default constructorIdUtterance(String sId)
Constructor for a string ID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Determines whether this identifies that same utterance as another object.Map<String,String>
getAttributes()
Getter forattributes
: Extended attributes of the utterance, including "prefix" for the result prefix, "name" for the search name, etc.String
getDefiningAnnotationUid()
Getter fordefiningAnnotationUid
: UID of the annotation that defines the bounds of this utterance, if any.Long
getEndAnchorId()
Getter forendAnchorId
: anchor_id of the anchor that is the end of the utterance.Double
getEndOffset()
Getter forendOffset
: The end offset, if known.Integer
getGraphId()
Getter forgraphId
: ag_id of the transcript.String
getId()
Generates an identifier for this utterance.String
getPrefix()
Result prefix, if any.Integer
getSpeakerNumber()
Getter forspeakerNumber
: speaker_number of the participant who spoke the utterance.Long
getStartAnchorId()
Getter forstartAnchorId
: anchor_id of the anchor that is the start of the utterance.Double
getStartOffset()
Getter forstartOffset
: The start offset, if known.IdUtterance
setDefiningAnnotationUid(String newDefiningAnnotationUid)
Setter fordefiningAnnotationUid
: UID of the annotation that defines the bounds of this utterance, if any.IdUtterance
setEndAnchorId(Long newEndAnchorId)
Setter forendAnchorId
: anchor_id of the anchor that is the end of the utterance.IdUtterance
setEndOffset(Double newEndOffset)
Setter forendOffset
: The end offset, if known.IdUtterance
setGraphId(Integer newGraphId)
Setter forgraphId
: ag_id of the transcript.void
setId(String sId)
Sets the utterance's attributes using the given identifierIdUtterance
setPrefix(String sNewPrefix)
Setter for result prefix, if any.IdUtterance
setSpeakerNumber(Integer newSpeakerNumber)
Setter forspeakerNumber
: speaker_number of the participant who spoke the utterance.IdUtterance
setStartAnchorId(Long newStartAnchorId)
Setter forstartAnchorId
: anchor_id of the anchor that is the start of the utterance.IdUtterance
setStartOffset(Double newStartOffset)
Setter forstartOffset
: The start offset, if known.String
toString()
String representation of this object - the same string returned bygetId()
-
-
-
Constructor Detail
-
IdUtterance
public IdUtterance()
Default constructor
-
IdUtterance
public IdUtterance(String sId)
Constructor for a string ID.- Parameters:
sId
- The utterance ID.
-
-
Method Detail
-
getGraphId
public Integer getGraphId()
Getter forgraphId
: ag_id of the transcript.- Returns:
- ag_id of the transcript.
-
setGraphId
public IdUtterance setGraphId(Integer newGraphId)
Setter forgraphId
: ag_id of the transcript.- Parameters:
newGraphId
- ag_id of the transcript.
-
getStartAnchorId
public Long getStartAnchorId()
Getter forstartAnchorId
: anchor_id of the anchor that is the start of the utterance.- Returns:
- anchor_id of the anchor that is the start of the utterance.
-
setStartAnchorId
public IdUtterance setStartAnchorId(Long newStartAnchorId)
Setter forstartAnchorId
: anchor_id of the anchor that is the start of the utterance.- Parameters:
newStartAnchorId
- anchor_id of the anchor that is the start of the utterance.
-
getEndAnchorId
public Long getEndAnchorId()
Getter forendAnchorId
: anchor_id of the anchor that is the end of the utterance.- Returns:
- anchor_id of the anchor that is the end of the utterance.
-
setEndAnchorId
public IdUtterance setEndAnchorId(Long newEndAnchorId)
Setter forendAnchorId
: anchor_id of the anchor that is the end of the utterance.- Parameters:
newEndAnchorId
- anchor_id of the anchor that is the end of the utterance.
-
getStartOffset
public Double getStartOffset()
Getter forstartOffset
: The start offset, if known.- Returns:
- The start offset, if known.
-
setStartOffset
public IdUtterance setStartOffset(Double newStartOffset)
Setter forstartOffset
: The start offset, if known.- Parameters:
newStartOffset
- The start offset, if known.
-
getEndOffset
public Double getEndOffset()
Getter forendOffset
: The end offset, if known.- Returns:
- The end offset, if known.
-
setEndOffset
public IdUtterance setEndOffset(Double newEndOffset)
Setter forendOffset
: The end offset, if known.- Parameters:
newEndOffset
- The end offset, if known.
-
getSpeakerNumber
public Integer getSpeakerNumber()
Getter forspeakerNumber
: speaker_number of the participant who spoke the utterance.- Returns:
- speaker_number of the participant who spoke the utterance.
-
setSpeakerNumber
public IdUtterance setSpeakerNumber(Integer newSpeakerNumber)
Setter forspeakerNumber
: speaker_number of the participant who spoke the utterance.- Parameters:
newSpeakerNumber
- speaker_number of the participant who spoke the utterance.
-
getDefiningAnnotationUid
public String getDefiningAnnotationUid()
Getter fordefiningAnnotationUid
: UID of the annotation that defines the bounds of this utterance, if any.- Returns:
- UID of the annotation that defines the bounds of this utterance, if any.
-
setDefiningAnnotationUid
public IdUtterance setDefiningAnnotationUid(String newDefiningAnnotationUid)
Setter fordefiningAnnotationUid
: UID of the annotation that defines the bounds of this utterance, if any.- Parameters:
newDefiningAnnotationUid
- UID of the annotation that defines the bounds of this utterance, if any.
-
getAttributes
public Map<String,String> getAttributes()
Getter forattributes
: Extended attributes of the utterance, including "prefix" for the result prefix, "name" for the search name, etc.- Returns:
- Extended attributes of the utterance, including "prefix" for the result prefix, "name" for the search name, etc.
-
setId
public void setId(String sId)
Sets the utterance's attributes using the given identifier- Parameters:
sId
- The ID.
-
getId
public String getId()
Generates an identifier for this utterance.- Returns:
- A uniformly-formatted identifier for this utterance.
-
getPrefix
public String getPrefix()
Result prefix, if any.- Returns:
- Result prefix, if any.
-
setPrefix
public IdUtterance setPrefix(String sNewPrefix)
Setter for result prefix, if any.- Parameters:
sNewPrefix
- Result prefix, if any.
-
toString
public String toString()
String representation of this object - the same string returned bygetId()
-
equals
public boolean equals(Object o)
Determines whether this identifies that same utterance as another object. This method ignores Prefix and any other extraneous properties.
-
-