com.aliasi.tag
Class Tagging<E>

java.lang.Object
  extended by com.aliasi.tag.Tagging<E>
Type Parameters:
E - Type of tokens in the tagging.
Direct Known Subclasses:
ScoredTagging, StringTagging

public class Tagging<E>
extends Object

A Tagging<E> represents a first-best assignment of a sequence of tags to a sequence of tokens of type E.

Since:
LingPipe3.9
Version:
3.9
Author:
Bob Carpenter

Constructor Summary
Tagging(List<E> tokens, List<String> tags)
          Construct a tagging with the specified list of tokens and tags.
 
Method Summary
 int size()
          Returns the number of tokens and tags in this tagging.
 String tag(int n)
          Return the tag in the specified position for this tagging.
 List<String> tags()
          Return an immutable list of tags for this tagging.
 E token(int n)
          Return the token in the specified position for this tagging.
 List<E> tokens()
          Return an immutable view of the tokens for this tagging.
 String toString()
          Return a string-based representation of this tagging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tagging

public Tagging(List<E> tokens,
               List<String> tags)
Construct a tagging with the specified list of tokens and tags. The lists are copied, so subsequent changes to the lists themselves will not matter.

Parameters:
tokens - List of tokens for the tagging.
tags - List of tags for the tagging.
Throws:
IllegalArgumentException - If the lists are not of the same size.
Method Detail

size

public int size()
Returns the number of tokens and tags in this tagging.

Returns:
The length of this tagging.

token

public E token(int n)
Return the token in the specified position for this tagging.

Parameters:
n - Position of token.
Returns:
Token at specified position.
Throws:
IndexOutOfBoundsException - If the position is out of range (n < 0 || n >= size()).

tag

public String tag(int n)
Return the tag in the specified position for this tagging.

Parameters:
n - Position of tag.
Returns:
Tag at specified position.
Throws:
IndexOutOfBoundsException - If the position is out of range (n < 0 || n >= size()).

tokens

public List<E> tokens()
Return an immutable view of the tokens for this tagging.

Returns:
The tokens for this tagging.

tags

public List<String> tags()
Return an immutable list of tags for this tagging.


toString

public String toString()
Return a string-based representation of this tagging.

Overrides:
toString in class Object
Returns:
String-based representation of this tagging.