de.fu_berlin.ties.combi
Class StrategyAdapter

java.lang.Object
  extended by de.fu_berlin.ties.combi.StrategyAdapter

public class StrategyAdapter
extends Object

A strategy adapter translates labels to the internal labels expected by a CombinationStrategy, using a list of regular expressions and replacement texts (or the other way around). This can be used to interpret labeling systems that follow the model of a specific combination strategy but use a different naming convention. For example, the state "O" (outside) usually used by IOB1/IOB2 tagging can be translated to the state "A" internally used by InsideOutsideStrategy. Note that patterns are matched against complete label texts, matches that cover only parts of label texts are not considered.

Instances of this class are not thread-safe and must be synchronized externally, if required.

Version:
$Revision: 1.5 $, $Date: 2006/10/21 16:04:01 $, $Author: siefkes $
Author:
Christian Siefkes

Constructor Summary
StrategyAdapter(LinkedHashMap<Pattern,String> replacements)
          Creates a new instance.
StrategyAdapter(TiesConfiguration conf)
          Creates a new instance.
 
Method Summary
static StrategyAdapter createDummyAdapter()
          Factory method for creating a dummy adapter that simple returns the labels generated by the combination strategy without modifying them in any way.
 String toString()
          Returns a string representation of this object.
 String[] translate(String[] labels)
          Translates the array of labels generated by a combination strategy to the corresponding labels following some external convention (or the other way around).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StrategyAdapter

public StrategyAdapter(TiesConfiguration conf)
Creates a new instance.

Parameters:
conf - used to configure this instance

StrategyAdapter

public StrategyAdapter(LinkedHashMap<Pattern,String> replacements)
Creates a new instance.

Parameters:
replacements - an ordered map from regex patterns to replacement texts
Method Detail

createDummyAdapter

public static StrategyAdapter createDummyAdapter()
Factory method for creating a dummy adapter that simple returns the labels generated by the combination strategy without modifying them in any way.

Returns:
a dummy adapter that doesn't modify any labels

translate

public String[] translate(String[] labels)
Translates the array of labels generated by a combination strategy to the corresponding labels following some external convention (or the other way around).

Parameters:
labels - the array of labels to translate
Returns:
a same-size array of labels translated by applying all configured replacements in the specified order

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation


Copyright © 2003-2007 Christian Siefkes. All Rights Reserved.