se.lth.cs.nlp.nlputils.annotations
Class Span

java.lang.Object
  extended by se.lth.cs.nlp.nlputils.annotations.Span

public class Span
extends Object

A span, that is a contiguous piece of text.

Author:
Richard Johansson (richard@cs.lth.se)

Field Summary
 int end
          The end of the span, exclusive.
 String id
           
 String label
           
static Comparator<Span> NESTING_ORDER
          A comparator that can be used to sort span according to nesting order.
 HashMap<String,Object> properties
          Properties.
 int start
          The start of the span, inclusive.
 int tokenEnd
          The end of the span as counted in tokens, exclusive.
 int tokenStart
          The start of the span as counted in tokens, inclusive.
 
Constructor Summary
Span()
           
 
Method Summary
 boolean matches(Span other)
          Returns true if this span has the same start and end and the same label as the other span.
 boolean matchesPartially(Span other)
          Returns true if this span overlaps and has the same label as the other span.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

label

public String label

id

public String id

start

public int start
The start of the span, inclusive.


end

public int end
The end of the span, exclusive.


tokenStart

public int tokenStart
The start of the span as counted in tokens, inclusive.


tokenEnd

public int tokenEnd
The end of the span as counted in tokens, exclusive.


properties

public HashMap<String,Object> properties
Properties.


NESTING_ORDER

public static final Comparator<Span> NESTING_ORDER
A comparator that can be used to sort span according to nesting order. Throws a RuntimeException if the spans cannot be nested.

Constructor Detail

Span

public Span()
Method Detail

matches

public boolean matches(Span other)
Returns true if this span has the same start and end and the same label as the other span.

Parameters:
other - the span to compare this span to.
Returns:
true if they match.

matchesPartially

public boolean matchesPartially(Span other)
Returns true if this span overlaps and has the same label as the other span.

Parameters:
other - the span to compare this span to.
Returns:
true if they overlap and have the same label.

toString

public String toString()
Overrides:
toString in class Object