Class Timex

java.lang.Object
edu.fiu.jtlex.data.Timex
All Implemented Interfaces:
INode, ITimex

public class Timex
extends java.lang.Object
implements ITimex
Default implementation of ITimex.
Author:
ceber003
  • Nested Class Summary

    Nested classes/interfaces inherited from interface edu.fiu.jtlex.data.ITimex

    ITimex.FunctionInDocument, ITimex.TimexMod, ITimex.TimexType
  • Constructor Summary

    Constructors 
    Constructor Description
    Timex​(int tID, ITimex.TimexType type, java.lang.String value, ITimex.TimexMod mod, boolean temporalFunction, int anchorID, ITimex.FunctionInDocument documentFunction, int beginPoint, int endPoint, java.lang.String quant, java.lang.String freq, java.lang.String phrase)
    Creates a new Timex with the specified information.
  • Method Summary

    Modifier and Type Method Description
    void addInLink​(ILink link)
    Add a link to the set of IN links from this node.
    void addOutLink​(ILink link)
    Add a link to the set of OUT links from this node.
    Timex clone()
    Creates and returns a copy of the Timex.
    int getAnchorTimeId()
    Returns the integer part of the anchortimeId.
    java.lang.String getAnchorTimeIdStr()
    Returns the string part of the anchortimeId.
    int getBeginPoint()
    Returns the integer part of the beginpointId.
    java.lang.String getBeginPointStr()
    Returns the string part of the beginpointId.
    int getEndPoint()
    Returns the integer part of the endpointId.
    java.lang.String getEndPointStr()
    Returns the string part of the endpointId.
    java.lang.String getFreq()
    Returns frequency String portion.
    ITimex.FunctionInDocument getFunction()
    Returns the function to which the object belongs.
    int getId()
    Returns the tID of the timex.
    java.lang.String getIdStr()
    Grabs the tID, adds a t to the front for String format and returns.
    java.util.Set<ILink> getInLinks()
    Returns the set of TimeML links which come to this node.
    ITimex.TimexMod getMod()
    Returns the mod to which the object belongs.
    java.util.Set<ILink> getOutLinks()
    Returns the set of TimeML links which come from this node.
    java.lang.String getPhrase()
    Returns the phrase from the text annotated as timex.
    java.lang.String getQuant()
    Returns the quantity to which the object belongs.
    boolean getTemporalFunction()
    Returns the inary attribute which expresses that the value of the temporal expression needs to be determined via evaluation of a temporal function.
    ITimex.TimexType getType()
    Returns the type of the timex.
    java.lang.String getValue()
    Returns the string representation of the value.
    boolean getValueDigits​(java.lang.String value)
    Returns true if the the value is at least 4 digits.
    void removeInLink​(ILink link)
    Removes a TimeML link from the set of links that end in this node.
    void removeOutLink​(ILink link)
    Removes a TimeML link from the set of links that start in this node.
    java.lang.String toJSON()
    Converts the Timex and its info into JSON format.
    java.lang.String toString()
    Returns the info of the Timex in String format.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface edu.fiu.jtlex.data.INode

    equals
  • Constructor Details

    • Timex

      public Timex​(int tID, ITimex.TimexType type, java.lang.String value, ITimex.TimexMod mod, boolean temporalFunction, int anchorID, ITimex.FunctionInDocument documentFunction, int beginPoint, int endPoint, java.lang.String quant, java.lang.String freq, java.lang.String phrase)
      Creates a new Timex with the specified information.
      Parameters:
      tID - id of the timex; may not be negative
      type - the type of the timex may not be null
      value - the value attribute of the timex
      mod - the mod of the value, is optional
      temporalFunction - true or false
      anchorID - the id of another timex anchored to the current timex, optional
      documentFunction - the function a timex is providing within the document, is 'NONE' when not specified.
      beginPoint - beginpoint is used if the timex is anchored to another, can be null
      endPoint - end is used if timex is anchored to another timex, can be null
      quant - used only if timex type is 'SET' is the literal describing the timex rate of occurrence
      freq - used only if timex type is 'SET' is the frequency the timex occurs
      phrase - the phase associated with this this timex.
      Throws:
      java.lang.NullPointerException - if type or value is null
      java.lang.IllegalArgumentException - if tID, acnhorId, beginPoint, or endPoint is negative
  • Method Details

    • getValueDigits

      public boolean getValueDigits​(java.lang.String value)
      Returns true if the the value is at least 4 digits. Also checks if value equals PXY, PAST_REF, PRESENT_REF or FUTURE_REF to return true.
      Parameters:
      value - a String that contains a numeric value
      Returns:
      true if the value has at least 4 digits
    • getId

      public int getId()
      Returns the tID of the timex.
      Specified by:
      getId in interface INode
      Returns:
      the tID of the timex.
    • getIdStr

      public java.lang.String getIdStr()
      Grabs the tID, adds a t to the front for String format and returns.
      Specified by:
      getIdStr in interface INode
      Returns:
      the tID of the timex in String format.
    • getType

      public ITimex.TimexType getType()
      Returns the type of the timex.
      Specified by:
      getType in interface INode
      Returns:
      the type of the timex.
    • getValue

      public java.lang.String getValue()
      Returns the string representation of the value. The value of the the timex tag determines what the actual amount of time for the date, time, duration, and set types.
      Specified by:
      getValue in interface ITimex
      Returns:
      the string representation of the value. May not be null.
    • getMod

      public ITimex.TimexMod getMod()
      Returns the mod to which the object belongs. This value is optional.
      Specified by:
      getMod in interface ITimex
      Returns:
      the mod to which the object belongs. May be null.
      See Also:
      ITimex.TimexMod
    • getTemporalFunction

      public boolean getTemporalFunction()
      Returns the inary attribute which expresses that the value of the temporal expression needs to be determined via evaluation of a temporal function.
      Specified by:
      getTemporalFunction in interface ITimex
      Returns:
      the inary attribute which expresses that the value of the temporal expression needs to be determined via evaluation of a temporal function.
    • getAnchorTimeId

      public int getAnchorTimeId()
      Returns the integer part of the anchortimeId. Each anchortime has to be identified by a unique ID number. This value is optional.
      Specified by:
      getAnchorTimeId in interface ITimex
      Returns:
      the integer part of the anchortimeId. May not be negative
    • getAnchorTimeIdStr

      public java.lang.String getAnchorTimeIdStr()
      Returns the string part of the anchortimeId. Each anchortime has to be identified by a unique ID number. This value is optional.
      Specified by:
      getAnchorTimeIdStr in interface ITimex
      Returns:
      the string part of the anchortimeId. May not be null.
    • getFunction

      public ITimex.FunctionInDocument getFunction()
      Returns the function to which the object belongs. Function in document can be one of seven values. If it is not specified then it will be set as 'NONE' by default.
      Specified by:
      getFunction in interface ITimex
      Returns:
      the function to which the object belongs. May be null.
    • getBeginPoint

      public int getBeginPoint()
      Returns the integer part of the beginpointId. Beginpoint is only used if the expression is anchored to another timex expression. Each beginpoint has to be identified by a unique ID number. If only endpoint is provided may create an empty timex to fill in.
      Specified by:
      getBeginPoint in interface ITimex
      Returns:
      the integer part of the beginpointId. May not be negative
    • getBeginPointStr

      public java.lang.String getBeginPointStr()
      Returns the string part of the beginpointId. Beginpoint is only used if the expression is anchored to another timex expression. Each beginpoint has to be identified by a unique ID number. If only endpoint is provided may create an empty timex to fill in.
      Specified by:
      getBeginPointStr in interface ITimex
      Returns:
      the string part of the beginpointId. May not be null.
    • getEndPoint

      public int getEndPoint()
      Returns the integer part of the endpointId. Endpoint is only used if the expression is anchored to another timex expression. Each endpoint has to be identified by a unique ID number. If only beginpoint is provided may create an empty timex to fill in.
      Specified by:
      getEndPoint in interface ITimex
      Returns:
      the integer part of the endpointId. May not be negative.
    • getEndPointStr

      public java.lang.String getEndPointStr()
      Returns the string part of the endpointId. Endpoint is only used if the expression is anchored to another timex expression. Each endpoint has to be identified by a unique ID number. If only beginpoint is provided may create an empty timex to fill in.
      Specified by:
      getEndPointStr in interface ITimex
      Returns:
      the string part of the endpointId. May not be null.
    • getQuant

      public java.lang.String getQuant()
      Returns the quantity to which the object belongs. The quant value is only used if the timex type is 'SET'.
      Specified by:
      getQuant in interface ITimex
      Returns:
      the quantity to which the object belongs. May be null.
    • getFreq

      public java.lang.String getFreq()
      Returns frequency String portion. The frequency value is only used if the timex type is 'SET'. The integer value determines the number of time the frequency takes. i.e: 2 Weeks, 3 Months, 1 Day, etc.
      Specified by:
      getFreq in interface ITimex
      Returns:
      frequency String portion. May be null.
    • getPhrase

      public java.lang.String getPhrase()
      Returns the phrase from the text annotated as timex.
      Specified by:
      getPhrase in interface ITimex
      Returns:
      the phrase from the text annotated as timex. May be null.
    • addOutLink

      public void addOutLink​(ILink link)
      Add a link to the set of OUT links from this node.
      Specified by:
      addOutLink in interface INode
      Specified by:
      addOutLink in interface ITimex
      Parameters:
      link - : A new OUT link from this node.
    • addInLink

      public void addInLink​(ILink link)
      Add a link to the set of IN links from this node.
      Specified by:
      addInLink in interface INode
      Specified by:
      addInLink in interface ITimex
      Parameters:
      link - : A new IN link incoming to this node.
    • getOutLinks

      public java.util.Set<ILink> getOutLinks()
      Returns the set of TimeML links which come from this node.
      Specified by:
      getOutLinks in interface INode
      Specified by:
      getOutLinks in interface ITimex
      Returns:
      the set of TimeML links which come from this node.
    • getInLinks

      public java.util.Set<ILink> getInLinks()
      Returns the set of TimeML links which come to this node.
      Specified by:
      getInLinks in interface INode
      Specified by:
      getInLinks in interface ITimex
      Returns:
      the set of TimeML links which come to this node.
    • removeOutLink

      public void removeOutLink​(ILink link)
      Removes a TimeML link from the set of links that start in this node.
      Specified by:
      removeOutLink in interface INode
      Specified by:
      removeOutLink in interface ITimex
      Parameters:
      link - a new OUT link to remove from the set of outgoing links.
    • removeInLink

      public void removeInLink​(ILink link)
      Removes a TimeML link from the set of links that end in this node.
      Specified by:
      removeInLink in interface INode
      Specified by:
      removeInLink in interface ITimex
      Parameters:
      link - a new In link to remove from the set of incoming links.
    • toString

      public java.lang.String toString()
      Returns the info of the Timex in String format.
      Overrides:
      toString in class java.lang.Object
      Returns:
      the info of the Timex in String format.
    • toJSON

      public java.lang.String toJSON()
      Converts the Timex and its info into JSON format.
      Specified by:
      toJSON in interface INode
      Returns:
      the JSON format of the Timex.
    • clone

      public Timex clone()
      Creates and returns a copy of the Timex.
      Specified by:
      clone in interface INode
      Returns:
      a copy of the Timex.