Class 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 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 for graphId: ag_id of the transcript.
        Returns:
        ag_id of the transcript.
      • setGraphId

        public IdUtterance setGraphId​(Integer newGraphId)
        Setter for graphId: ag_id of the transcript.
        Parameters:
        newGraphId - ag_id of the transcript.
      • getStartAnchorId

        public Long getStartAnchorId()
        Getter for startAnchorId: 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 for startAnchorId: 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 for endAnchorId: 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 for endAnchorId: 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 for startOffset: The start offset, if known.
        Returns:
        The start offset, if known.
      • setStartOffset

        public IdUtterance setStartOffset​(Double newStartOffset)
        Setter for startOffset: The start offset, if known.
        Parameters:
        newStartOffset - The start offset, if known.
      • getEndOffset

        public Double getEndOffset()
        Getter for endOffset: The end offset, if known.
        Returns:
        The end offset, if known.
      • setEndOffset

        public IdUtterance setEndOffset​(Double newEndOffset)
        Setter for endOffset: The end offset, if known.
        Parameters:
        newEndOffset - The end offset, if known.
      • getSpeakerNumber

        public Integer getSpeakerNumber()
        Getter for speakerNumber: 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 for speakerNumber: 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 for definingAnnotationUid: 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 for definingAnnotationUid: 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 for attributes: 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 by getId()
        Overrides:
        toString in class Object
        Returns:
        The same string returned by getId()
      • 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.
        Overrides:
        equals in class Object
        Parameters:
        o - The other object.
        Returns:
        true if they both identify the same stretch of speech by the same participant, false otherwise