com.aliasi.corpus
Class ChunkTagHandlerAdapter

java.lang.Object
  extended by com.aliasi.corpus.ChunkTagHandlerAdapter
All Implemented Interfaces:
Handler, TagHandler

Deprecated. Use TagChunkCodecAdapters.chunkingToStringTagging(TagChunkCodec,ObjectHandler) instead.

@Deprecated
public class ChunkTagHandlerAdapter
extends Object
implements TagHandler

A ChunkTagHandlerAdapter converts a chunk handler to a BIO-coded tag handler. The adapters handles BIO-encoded taggings by converting them to chunkings and then delegating them to the contained chunk handler.

For the definition of the BIO encoding scheme and an example, see ChunkHandlerAdapter. This class performs the inverse adaptation, taking the array of whitespaces, tokens and tags and producing the specified chunking. Unlike the case for adapting tag handlers, there is no need to specify a tokenizer factory and no possibility of taggings being inconsistent with a chunk handler.

The static method toChunkingBIO(String[],String[],String[]) is used to convert BIO-coded taggings to chunkings.

Since:
LingPipe2.1
Version:
3.9
Author:
Bob Carpenter

Field Summary
static String BEGIN_TAG_PREFIX
          Deprecated. The prefix to which a tag is appended to produce a begin tag, namely "B-".
static String IN_TAG_PREFIX
          Deprecated. The prefix to which a tag is appended to produce a continuation, or "in" tag, namely "I-".
static String OUT_TAG
          Deprecated. The tag assigned to tokens that are not in a chunk, namely "O" (the letter O).
 
Constructor Summary
ChunkTagHandlerAdapter()
          Deprecated. Construct a tag handler with no specified chunk handler.
ChunkTagHandlerAdapter(ObjectHandler<Chunking> handler)
          Deprecated. Construct a tag handler adapter with the specified chunk handler.
 
Method Summary
 void handle(String[] tokens, String[] whitespaces, String[] tags)
          Deprecated. Handle the specified arrays of tokens, whitespaces and tags.
static boolean isBeginTag(String tag)
          Deprecated. Returns true if the specified tag is the first token in a chunk.
static boolean isInTag(String tag)
          Deprecated. Returns true if the specified tag is for the continuation of a chunk.
static boolean isOutTag(String tag)
          Deprecated. Returns true if the specified tag is for the first token in a chunk.
 void setChunkHandler(ObjectHandler<Chunking> handler)
          Deprecated. Sets the contained chunk handler to the specified value.
static String toBaseTag(String tag)
          Deprecated. Returns the base tag for the specified begin or continuation tag.
static String toBeginTag(String type)
          Deprecated. Returns the begin tag for the specified type.
static Chunking toChunkingBIO(String[] tokens, String[] whitespaces, String[] tags)
          Deprecated. Converts the BIO-coded tokens, whitespaces and tags into a chunking.
static String toInTag(String type)
          Deprecated. Returns the continuation tag for the specified type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OUT_TAG

public static String OUT_TAG
Deprecated. 
The tag assigned to tokens that are not in a chunk, namely "O" (the letter O).


BEGIN_TAG_PREFIX

public static String BEGIN_TAG_PREFIX
Deprecated. 
The prefix to which a tag is appended to produce a begin tag, namely "B-".


IN_TAG_PREFIX

public static String IN_TAG_PREFIX
Deprecated. 
The prefix to which a tag is appended to produce a continuation, or "in" tag, namely "I-".

Constructor Detail

ChunkTagHandlerAdapter

public ChunkTagHandlerAdapter()
Deprecated. 
Construct a tag handler with no specified chunk handler. The handler may be set after construction using setChunkHandler(ObjectHandler), and must be called at least once before handling input taggings if this constructor is used.


ChunkTagHandlerAdapter

public ChunkTagHandlerAdapter(ObjectHandler<Chunking> handler)
Deprecated. 
Construct a tag handler adapter with the specified chunk handler. The handler may be set after construction using setChunkHandler(ObjectHandler).

Parameters:
handler - Chunk handler.
Method Detail

setChunkHandler

public void setChunkHandler(ObjectHandler<Chunking> handler)
Deprecated. 
Sets the contained chunk handler to the specified value. Calls to handle taggings with handle(String[],String[],String[]) result in the correspdoning chunking being created and passed to the specified chunk handler.

Parameters:
handler - Chunk handler.

handle

public void handle(String[] tokens,
                   String[] whitespaces,
                   String[] tags)
Deprecated. 
Handle the specified arrays of tokens, whitespaces and tags. This adpater first converts the three parallel arrays to a chunking and then passes the chunking to the contained chunk handler. If the arrays are not validly BIO-coded, an exception is raised.

The token and tag arrays must be the same length. The whitespaces array may be null, in which case each space is treated as a single whitespace character (' '). If the whitespaces array is not null, it must be one element longer than the tokens array.

If the chunk handler has not been set in the construct or by setChunkHandler(ObjectHandler), this call will raise a null pointer exception.

Specified by:
handle in interface TagHandler
Parameters:
tokens - Array of tokens.
whitespaces - Array of whitespaces.
tags - Array of tags.
Throws:
IllegalArgumentException - If the tokens, whitespaces and tags are not aligned.

toBaseTag

public static String toBaseTag(String tag)
Deprecated. 
Returns the base tag for the specified begin or continuation tag. If the tag is a begin tag or a continuation tag, its suffix, representing its type, is returned. In all other cases, an exception is raised.

Parameters:
tag - Tag to convert to base form.
Returns:
Base form of tag.

isBeginTag

public static boolean isBeginTag(String tag)
Deprecated. 
Returns true if the specified tag is the first token in a chunk. The first token is labeled with a begin tag, consisting of the begin-tag prefix BEGIN_TAG_PREFIX appended to a type.

Parameters:
tag - Tag to test.
Returns:
true if the tag is for the first token in a chunk.

isOutTag

public static boolean isOutTag(String tag)
Deprecated. 
Returns true if the specified tag is for the first token in a chunk. The first token is labeled with a begin tag, consisting of the begin-tag prefix BEGIN_TAG_PREFIX appended to a type.

Parameters:
tag - Tag to test.
Returns:
true if the tag is for the first token in a chunk.

isInTag

public static boolean isInTag(String tag)
Deprecated. 
Returns true if the specified tag is for the continuation of a chunk. A continuation token is labeled with a continuation or "in" tag, consisting of the in-tag prefix IN_TAG_PREFIX appended to a type.

Parameters:
tag - Tag to test.
Returns:
true if the tag is for the continuation of a chunk.

toInTag

public static String toInTag(String type)
Deprecated. 
Returns the continuation tag for the specified type. The return value is the IN_TAG_PREFIX constant prepended to the specified type.

Parameters:
type - Type to convert to continuation tag.
Returns:
Continuation tag for specified type.

toBeginTag

public static String toBeginTag(String type)
Deprecated. 
Returns the begin tag for the specified type. The return value is the BEGIN_TAG_PREFIX constant prepended to the specified type.

Parameters:
type - Type to convert to begin tag.
Returns:
The begin tag for the specified type.

toChunkingBIO

public static Chunking toChunkingBIO(String[] tokens,
                                     String[] whitespaces,
                                     String[] tags)
Deprecated. 
Converts the BIO-coded tokens, whitespaces and tags into a chunking. This algorithm is not actually sensitive to other categories than the BI marked ones.

Parameters:
tokens - Tokens for tagging.
whitespaces - Whitespaces for tagging.
tags - BIO-coded tags.
Returns:
The chunking derived from the BIO-coded tagging.