edu.washington.cs.knowitall.rule.constraint
Class Constraint

java.lang.Object
  extended by edu.washington.cs.knowitall.rule.constraint.Constraint
Direct Known Subclasses:
CaptureConstraint

public abstract class Constraint
extends Object

A representation of a rule constraint. A rule constraint is applied to an extraction and yields true if it passes.

Author:
schmmd

Field Summary
 ExtractionPart part
           
 
Constructor Summary
protected Constraint(org.jdom.Element e)
          Common deserialization from an element.
  Constraint(ExtractionPart part)
          Constructs a new constraint on the specified extraction part.
 
Method Summary
 Boolean check(RelationExtraction extraction)
          Check the constraint against the supplied extraction.
protected abstract  Boolean check(TokenSequence extraction)
           
static Constraint create(Class<?> tagger, Class<?>[] argTypes, Object[] argValues)
           
static Constraint create(String classname)
           
static Constraint create(String classname, Class<?>[] argTypes, Object[] argValues)
           
 boolean equals(Object other)
          Force subclasses to avoid pointer-based comparison.
static Constraint fromXmlElement(org.jdom.Element e)
           
abstract  List<Constraint> generalize()
          Creates a list of constraints with constraint size reduced by exactly one.
static Class<?> getConstraintClass(String classname)
           
 int hashCode()
          Force subclasses to avoid pointer-based comparison.
 Constraint simplify()
          Simplifies a constraint.
abstract  int size()
          The size of a constraint is the count of subconstraints.
 boolean subsumes(Constraint other)
          Checks is a constraint is weakly stricter than the other.
 String toString()
          Provides a base constraint representation.
 String toString(Iterable<?> args)
          Combines arguments into a common constraint representation.
 String toString(String arg)
          Combines the argument into a common constraint representation.
 org.jdom.Element toXmlElement()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

part

public final ExtractionPart part
Constructor Detail

Constraint

protected Constraint(org.jdom.Element e)
Common deserialization from an element. Deserializes the extraction part.

Parameters:
e -

Constraint

public Constraint(ExtractionPart part)
Constructs a new constraint on the specified extraction part.

Parameters:
part -
Method Detail

check

public Boolean check(RelationExtraction extraction)
Check the constraint against the supplied extraction.

Parameters:
relation -
Returns:

equals

public boolean equals(Object other)
Force subclasses to avoid pointer-based comparison.

Overrides:
equals in class Object

hashCode

public int hashCode()
Force subclasses to avoid pointer-based comparison.

Overrides:
hashCode in class Object

toString

public String toString()
Provides a base constraint representation. Constraint(part=LEFT)

Overrides:
toString in class Object
Parameters:
args -
Returns:

toString

public String toString(String arg)
Combines the argument into a common constraint representation. StringConstraint(part=LEFT, string=foo)

Parameters:
args -
Returns:

toString

public String toString(Iterable<?> args)
Combines arguments into a common constraint representation. TermConstraint(part=LEFT, StringRestriction(foo), TypeRestriction(type))

Parameters:
args -
Returns:

check

protected abstract Boolean check(TokenSequence extraction)
Parameters:
extraction -
Returns:
true if the constraint passes

size

public abstract int size()
The size of a constraint is the count of subconstraints. Most constraints will have a size of one. However TermConstraint for example has a size equal to the number of restrictions it has.

Returns:

generalize

public abstract List<Constraint> generalize()
Creates a list of constraints with constraint size reduced by exactly one.

Returns:

subsumes

public boolean subsumes(Constraint other)
Checks is a constraint is weakly stricter than the other.

Parameters:
other - constraint to compare against
Returns:
true if the other constraint is redundant

simplify

public Constraint simplify()
Simplifies a constraint. The resulting constraint should be identical functionally.

Returns:
the simplified constraint

getConstraintClass

public static Class<?> getConstraintClass(String classname)
                                   throws ClassNotFoundException
Throws:
ClassNotFoundException

create

public static Constraint create(String classname,
                                Class<?>[] argTypes,
                                Object[] argValues)
                         throws ClassNotFoundException,
                                SecurityException,
                                IllegalArgumentException,
                                NoSuchMethodException,
                                InstantiationException,
                                IllegalAccessException,
                                InvocationTargetException
Throws:
ClassNotFoundException
SecurityException
IllegalArgumentException
NoSuchMethodException
InstantiationException
IllegalAccessException
InvocationTargetException

create

public static Constraint create(Class<?> tagger,
                                Class<?>[] argTypes,
                                Object[] argValues)
                         throws SecurityException,
                                NoSuchMethodException,
                                IllegalArgumentException,
                                InstantiationException,
                                IllegalAccessException,
                                InvocationTargetException
Throws:
SecurityException
NoSuchMethodException
IllegalArgumentException
InstantiationException
IllegalAccessException
InvocationTargetException

create

public static Constraint create(String classname)
                         throws ClassNotFoundException,
                                SecurityException,
                                IllegalArgumentException,
                                NoSuchMethodException,
                                InstantiationException,
                                IllegalAccessException,
                                InvocationTargetException
Throws:
ClassNotFoundException
SecurityException
IllegalArgumentException
NoSuchMethodException
InstantiationException
IllegalAccessException
InvocationTargetException

fromXmlElement

public static Constraint fromXmlElement(org.jdom.Element e)

toXmlElement

public org.jdom.Element toXmlElement()


Copyright © 2011 University of Washington CSE. All Rights Reserved.