ch.uzh.ifi.attempto.chartparser
Class FeatureMap

java.lang.Object
  extended by ch.uzh.ifi.attempto.chartparser.FeatureMap

public class FeatureMap
extends java.lang.Object

This class represents a set of features consisting of name/value pairs.

Author:
Tobias Kuhn

Constructor Summary
FeatureMap()
          Creates an empty feature map.
 
Method Summary
 boolean canUnify(FeatureMap featureMap)
          This method detects whether this feature map can unify with the given feature map.
 FeatureMap deepCopy()
          Creates a deep copy of this feature map.
 StringRef getFeature(java.lang.String featureName)
          Returns a feature value.
 java.util.Set<java.lang.String> getFeatureNames()
          Returns the used feature names.
 java.util.Collection<StringRef> getFeatureValues()
          Returns the used feature values.
 boolean isSimilar(FeatureMap fm)
          This methods checks whether two feature maps are similar.
 void setFeature(java.lang.String featureName, StringRef featureValue)
          Sets a feature.
 void skolemize()
          Skolemizes the feature values of this feature map.
 java.lang.String toString()
           
 void tryToUnify(FeatureMap featureMap)
          Tries to unify this feature map with another feature map.
 void unify(FeatureMap featureMap)
          Unifies this feature map with another feature map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FeatureMap

public FeatureMap()
Creates an empty feature map.

Method Detail

setFeature

public void setFeature(java.lang.String featureName,
                       StringRef featureValue)
Sets a feature. If the feature is already present, the feature value is overridden and not unified.

Parameters:
featureName - The name of the feature to set.
featureValue - The feature value.

getFeature

public StringRef getFeature(java.lang.String featureName)
Returns a feature value.

Parameters:
featureName - The name of the feature.
Returns:
The value of the feature.

unify

public void unify(FeatureMap featureMap)
           throws UnificationFailedException
Unifies this feature map with another feature map. Two feature maps can unify if and only if all values of common feature name unify. If the unification fails, a UnificationFailedException is thrown. In this case, the two feature maps remain partly unified, i.e. no backtracking is done. Thus, this operation should be perfomed only if it is certain that the unification succeeds, or if the operation is performed on copies of objects that are not used anymore afterwards.

Parameters:
featureMap - The feature map to be unified with this feature map.
Throws:
UnificationFailedException - If unification fails.

tryToUnify

public void tryToUnify(FeatureMap featureMap)
                throws UnificationFailedException
Tries to unify this feature map with another feature map. If unification is not possible, an exception is thrown. In the case unification would be possible, the unification is not performed completely. In any case the two feature maps remain in an unconsistent state afterwards. Thus, this operation should be performed only on copies of objects that are not used anymore afterwards.

Parameters:
featureMap - The feature map to be unified with this feature map.
Throws:
UnificationFailedException - If unification fails.

canUnify

public boolean canUnify(FeatureMap featureMap)
This method detects whether this feature map can unify with the given feature map. Neither of the two feature maps are changed.

Parameters:
featureMap - The feature map for the unification check.
Returns:
true if the two feature map can unify.

skolemize

public void skolemize()
Skolemizes the feature values of this feature map.


isSimilar

public boolean isSimilar(FeatureMap fm)
This methods checks whether two feature maps are similar. Two feature maps are similar if and only if they do not share a feature with the same name but with values that do not unify locally (i.e. without considering the unifications entailed by other features).

Parameters:
fm - The category for which similarity with this category should be checked.
Returns:
true if the two categories are similar.

deepCopy

public FeatureMap deepCopy()
Creates a deep copy of this feature map.

Returns:
A deep copy.

getFeatureNames

public java.util.Set<java.lang.String> getFeatureNames()
Returns the used feature names.

Returns:
The used feature names.

getFeatureValues

public java.util.Collection<StringRef> getFeatureValues()
Returns the used feature values.

Returns:
The used feature values.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright 2008-2012, AceWiki developers