de.danielnaber.languagetool.rules.patterns
Class Unifier

Object
  extended by Unifier

public class Unifier
extends Object

Implements unification of features over tokens.

Author:
Marcin Milkowski

Constructor Summary
Unifier()
          Instantiates the unifier.
 
Method Summary
 AnalyzedTokenReadings[] getFinalUnified()
          Used for getting a unified sequence in case when simple test method isUnified(de.danielnaber.languagetool.AnalyzedToken, java.lang.String, java.lang.String, boolean, boolean) was used.
 boolean getNegation()
           
 AnalyzedTokenReadings[] getUnifiedTokens()
          Gets a full sequence of filtered tokens.
 boolean isSatisfied(AnalyzedToken aToken, String feature, String type)
          Tests if a token has shared features with other tokens.
 boolean isUnified(AnalyzedToken matchToken, String feature, String type, boolean isUniNegated, boolean lastReading)
          Tests if the token sequence is unified.
 void reset()
          Resets after use of unification.
 void setEquivalence(String feature, String type, Element elem)
          Prepares equivalence types for features to be tested.
 void setNegation(boolean neg)
           
 void startNextToken()
          Call after every complete token (AnalyzedTokenReadings) checked.
 void startUnify()
          Starts testing only those equivalences that were previously matched.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Unifier

public Unifier()
Instantiates the unifier.

Method Detail

setEquivalence

public final void setEquivalence(String feature,
                                 String type,
                                 Element elem)
Prepares equivalence types for features to be tested. All equivalence types are given as Elements. They create an equivalence set (with abstraction).

Parameters:
feature - Feature to be tested, like gender, grammatical case or number.
type - Type of equivalence for the feature, for example plural, first person, genitive.
elem - Element specifying the equivalence.

isSatisfied

public final boolean isSatisfied(AnalyzedToken aToken,
                                 String feature,
                                 String type)
Tests if a token has shared features with other tokens.

Parameters:
aToken - - token to be tested
feature - - feature to be tested
type - - type of equivalence relation for the feature
Returns:
true if the token shares this type of feature with other tokens

startNextToken

public final void startNextToken()
Call after every complete token (AnalyzedTokenReadings) checked.


startUnify

public final void startUnify()
Starts testing only those equivalences that were previously matched.


setNegation

public final void setNegation(boolean neg)

getNegation

public final boolean getNegation()

reset

public final void reset()
Resets after use of unification. Required.


getUnifiedTokens

public final AnalyzedTokenReadings[] getUnifiedTokens()
Gets a full sequence of filtered tokens.

Returns:
Array of AnalyzedTokenReadings that match equivalence relation defined for features tested.

isUnified

public final boolean isUnified(AnalyzedToken matchToken,
                               String feature,
                               String type,
                               boolean isUniNegated,
                               boolean lastReading)
Tests if the token sequence is unified.

Parameters:
matchToken - AnalyzedToken token to unify
feature - String: feature to unify over
type - String: value types of the feature
isUniNegated - if true, then return negated result
lastReading - true when the matchToken is the last reading in the AnalyzedReadings
Returns:
True if the tokens in the sequence are unified.

getFinalUnified

public final AnalyzedTokenReadings[] getFinalUnified()
Used for getting a unified sequence in case when simple test method isUnified(de.danielnaber.languagetool.AnalyzedToken, java.lang.String, java.lang.String, boolean, boolean) was used.

Returns:
An array of AnalyzedTokenReadings


Copyright © 2005-2009 Daniel Naber