edu.stanford.nlp.ie.machinereading.structure
Class Span

java.lang.Object
  extended by edu.stanford.nlp.ie.machinereading.structure.Span
All Implemented Interfaces:
java.io.Serializable

public class Span
extends java.lang.Object
implements java.io.Serializable

Stores the offsets for a span of text Offsets may indicate either token or byte positions Start is inclusive, end is exclusive

Author:
Mihai
See Also:
Serialized Form

Constructor Summary
Span(int s, int e)
          This assumes that s <= e.
Span(Span... spans)
          Creates a span that encloses all spans in the argument list.
 
Method Summary
 boolean contains(int i)
          Returns true if i is inside this span.
 boolean contains(Span otherSpan)
          Returns true if this span contains otherSpan.
 int end()
           
 boolean equals(java.lang.Object other)
           
 void expandToInclude(Span otherSpan)
           
static Span fromValues(int val1, int val2)
          Safe way to construct Spans if you're not sure which value is higher.
 int hashCode()
           
 boolean isAfter(Span otherSpan)
          Returns true if this span starts after the otherSpan's end.
 boolean isBefore(Span otherSpan)
          Returns true if this span ends before the otherSpan starts.
 void setEnd(int e)
           
 void setStart(int s)
           
 int start()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Span

public Span(int s,
            int e)
This assumes that s <= e. Use fromValues if you can't guarantee this.


Span

public Span(Span... spans)
Creates a span that encloses all spans in the argument list. Behavior is undefined if given no arguments.

Method Detail

fromValues

public static Span fromValues(int val1,
                              int val2)
Safe way to construct Spans if you're not sure which value is higher.


start

public int start()

end

public int end()

setStart

public void setStart(int s)

setEnd

public void setEnd(int e)

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

expandToInclude

public void expandToInclude(Span otherSpan)

contains

public boolean contains(Span otherSpan)
Returns true if this span contains otherSpan. Endpoints on spans may match.


contains

public boolean contains(int i)
Returns true if i is inside this span. Note that the start is inclusive and the end is exclusive.


isBefore

public boolean isBefore(Span otherSpan)
Returns true if this span ends before the otherSpan starts.

Throws:
java.lang.IllegalArgumentException - if either span contains the other span

isAfter

public boolean isAfter(Span otherSpan)
Returns true if this span starts after the otherSpan's end.

Throws:
java.lang.IllegalArgumentException - if either span contains the other span


Stanford NLP Group