ch.uzh.ifi.attempto.chartparser
Class Category

java.lang.Object
  extended by ch.uzh.ifi.attempto.chartparser.Category
Direct Known Subclasses:
Nonterminal, Terminal

public abstract class Category
extends java.lang.Object

This class represents a grammatical category.

Author:
Tobias Kuhn

Constructor Summary
Category(java.lang.String name)
          Creates a new category.
 
Method Summary
 boolean canUnify(Category category)
          This method detects whether this category can unify with the given category.
 Category deepCopy()
          Creates a deep copy of this category.
 boolean equals(java.lang.Object obj)
           
 StringRef getFeature(java.lang.String featureName)
          Returns a feature value.
 FeatureMap getFeatureMap()
          Returns the map of features of this category.
 java.lang.String getName()
          Returns the name of the category.
 boolean isReference()
          Returns true if this category is a reference.
 boolean isSimilar(Category c)
          This methods checks whether two categories are similar.
 void setFeature(java.lang.String featureName, java.lang.String featureValue)
          Sets a feature.
 void setFeature(java.lang.String featureName, StringRef featureValue)
          Sets a feature.
 void skolemize()
          Skolemizes the feature values of this category.
 boolean subsumes(Category category)
          This method returns true if this category subsumes (i.e.
 java.lang.String toString()
           
 void tryToUnify(Category category)
          Tries to unify this category with another category.
 void unify(Category category)
          Unifies this category with another category.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Category

public Category(java.lang.String name)
Creates a new category.

Parameters:
name - The name of the category.
Method Detail

isReference

public boolean isReference()
Returns true if this category is a reference.

Returns:
true if this is a reference.

getName

public java.lang.String getName()
Returns the name of the category.

Returns:
The name of the category.

getFeatureMap

public FeatureMap getFeatureMap()
Returns the map of features of this category.

Returns:
The feature map.

setFeature

public void setFeature(java.lang.String featureName,
                       StringRef featureValue)
Sets a feature.

Parameters:
featureName - The feature name
featureValue - The string reference that points to the value of the feature.

setFeature

public void setFeature(java.lang.String featureName,
                       java.lang.String featureValue)
Sets a feature.

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

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(Category category)
           throws UnificationFailedException
Unifies this category with another category. Two categories can unify if and only if they have the same names and they have no features with conflicting values. If the unification fails, a UnificationFailedException is thrown. In this case, the two categories 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:
category - The category to be unified with this category.
Throws:
UnificationFailedException - If unification fails.

tryToUnify

public void tryToUnify(Category category)
                throws UnificationFailedException
Tries to unify this category with another category. 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 categories remain in an unconsistent state afterwards. Thus, this operation should be performed only on copies of objects that are not used anymore afterwards.

Parameters:
category - The category to be unified with this category.
Throws:
UnificationFailedException - If unification fails.

canUnify

public boolean canUnify(Category category)
This method detects whether this category can unify with the given category. Neither of the two categories are changed.

Parameters:
category - The category for the unification check.
Returns:
true if the two categories can unify.

skolemize

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


deepCopy

public Category deepCopy()
Creates a deep copy of this category.

Returns:
A deep copy.

isSimilar

public boolean isSimilar(Category c)
This methods checks whether two categories are similar. Two categories are similar if and only if the categories have the same name and no feature with the same name is present in both categories with values that do not unify locally.

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

subsumes

public boolean subsumes(Category category)
This method returns true if this category subsumes (i.e. is more general than) the given category, or false otherwise.

Parameters:
category - The category for which it is checked whether this category subsumes it.
Returns:
true if this category subsumes the given category.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

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


Copyright 2008-2009, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch)