com.aliasi.crf
Class ChainCrfFeatures<E>

java.lang.Object
  extended by com.aliasi.crf.ChainCrfFeatures<E>
Type Parameters:
E - Type of tokens in the tagging.

public abstract class ChainCrfFeatures<E>
extends Object

The ChainCrfFeatures interface specifies methods for extracting node and edge features for a conditional random field.

Use by CRFs

Typically, these features will be created by an implementation of ChainCrfFeatureExtractor in the context of CRF training or tagging. In this case, the previous tag is guaranteed to fall in the set of tags provided at construction time.

Caching High Cost Features

During construction, the features implementation may cache values, such as part-of-speech tags for CRF chunker features.

Thread Safety

After safely publishing the constructed features, the feature extraction methods should be thread safe. The read methods implemented by this class are all thread safe.

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

Constructor Summary
ChainCrfFeatures(List<E> tokens, List<String> tags)
          Construct a chain CRF feature set for the specified lists of input tokens and possible output tags.
 
Method Summary
abstract  Map<String,? extends Number> edgeFeatures(int n, int previousTagIndex)
          Return the edge features for the specified input position and index of the previous tag.
abstract  Map<String,? extends Number> nodeFeatures(int n)
          Return the node features for the specified input position.
 int numTags()
          Returns the number of possible output tags for this feature set.
 int numTokens()
          Returns the number of tokens for this feature set.
 String tag(int k)
          Return the output tag with the specified index.
 E token(int n)
          Return the token at the specified input position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChainCrfFeatures

public ChainCrfFeatures(List<E> tokens,
                        List<String> tags)
Construct a chain CRF feature set for the specified lists of input tokens and possible output tags.

Parameters:
tokens - Input tokens.
tags - Possible output tags.
Method Detail

numTokens

public int numTokens()
Returns the number of tokens for this feature set.

Returns:
Number of tokens for this feature set.

token

public E token(int n)
Return the token at the specified input position.

Parameters:
n - Input position.
Returns:
Token at specified index position.
Throws:
IndexOutOfBoundsException - If the specified input position is less than 0 or greater than or equal to the number of tokens.

numTags

public int numTags()
Returns the number of possible output tags for this feature set.

Returns:
Number of possible output tags.

tag

public String tag(int k)
Return the output tag with the specified index.

Returns:
Output tag for index.
Throws:
IndexOutOfBoundsException - If the specified index is less than 0 or greater than or equal to the number of tokens.

nodeFeatures

public abstract Map<String,? extends Number> nodeFeatures(int n)
Return the node features for the specified input position.

Parameters:
n - Position in input token sequence.
Returns:
Features for the node at the specified position.
Throws:
IndexOutOfBoundsException - If the specifieid token position is out of bounds.

edgeFeatures

public abstract Map<String,? extends Number> edgeFeatures(int n,
                                                          int previousTagIndex)
Return the edge features for the specified input position and index of the previous tag.

Parameters:
n - Position in input token sequence.
previousTagIndex - Index of previous tag in list of tags.
Throws:
IndexOutOfBoundsException - If the specifieid token position or tag index are out of bounds.