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

java.lang.Object
  extended by edu.washington.cs.knowitall.rule.constraint.Constraint
      extended by edu.washington.cs.knowitall.rule.constraint.CaptureConstraint
          extended by edu.washington.cs.knowitall.rule.constraint.AbstractPatternConstraint
              extended by edu.washington.cs.knowitall.rule.constraint.TermConstraint

public class TermConstraint
extends AbstractPatternConstraint

Constrains based on the existance of a term. A term is a range of text that matches all of the associated restrictions. Any of the following can be associated as a restriction: StringConstraint ChunkConstraint TypeConstraint LemmaConstraint

Author:
schmmd

Nested Class Summary
static class TermConstraint.ChunkRequirement
          Require the associated chunk tag.
static class TermConstraint.LemmaRequirement
          Require the associated lemma.
static class TermConstraint.PosRequirement
          Require the associated POS tag.
static class TermConstraint.Requirement
          A subconstraint of a TermConstraint.
static class TermConstraint.StringRequirement
          Require the associated string.
static class TermConstraint.TypeRequirement
          Require the associated type.
 
Field Summary
 Set<TermConstraint.Requirement> requirements
           
 
Fields inherited from class edu.washington.cs.knowitall.rule.constraint.AbstractPatternConstraint
expression
 
Fields inherited from class edu.washington.cs.knowitall.rule.constraint.Constraint
part
 
Constructor Summary
  TermConstraint(org.jdom.Element e)
           
protected TermConstraint(org.jdom.Element e, ExtractionPart part)
           
  TermConstraint(ExtractionPart part, List<TermConstraint.Requirement> requirements)
           
  TermConstraint(ExtractionPart part, TermConstraint.Requirement requirement)
           
 
Method Summary
protected static String buildPattern(List<TermConstraint.Requirement> requirements)
          Build a pattern from the list of requirements.
protected  String deserializePattern(org.jdom.Element e)
          Deserialize the sequence of term constraints in the XML element into a token-based pattern.
 boolean equals(Object other)
          Force subclasses to avoid pointer-based comparison.
 List<Constraint> generalize()
          Generalize by removing a subconstraint.
 int hashCode()
          Force subclasses to avoid pointer-based comparison.
 String pattern()
           
 Constraint simplify()
          If there are no constraints, this constraint may be removed.
 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.
 org.jdom.Element toSubsequenceXmlElement()
           
 org.jdom.Element toXmlElement()
           
 
Methods inherited from class edu.washington.cs.knowitall.rule.constraint.AbstractPatternConstraint
check, getString, value
 
Methods inherited from class edu.washington.cs.knowitall.rule.constraint.CaptureConstraint
value
 
Methods inherited from class edu.washington.cs.knowitall.rule.constraint.Constraint
check, create, create, create, fromXmlElement, getConstraintClass, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

requirements

public final Set<TermConstraint.Requirement> requirements
Constructor Detail

TermConstraint

public TermConstraint(org.jdom.Element e)

TermConstraint

protected TermConstraint(org.jdom.Element e,
                         ExtractionPart part)

TermConstraint

public TermConstraint(ExtractionPart part,
                      List<TermConstraint.Requirement> requirements)

TermConstraint

public TermConstraint(ExtractionPart part,
                      TermConstraint.Requirement requirement)
Method Detail

toString

public String toString()
Description copied from class: Constraint
Provides a base constraint representation. Constraint(part=LEFT)

Overrides:
toString in class Constraint

equals

public boolean equals(Object other)
Description copied from class: Constraint
Force subclasses to avoid pointer-based comparison.

Overrides:
equals in class AbstractPatternConstraint

hashCode

public int hashCode()
Description copied from class: Constraint
Force subclasses to avoid pointer-based comparison.

Overrides:
hashCode in class Constraint

size

public int size()
Description copied from class: Constraint
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.

Specified by:
size in class Constraint
Returns:

pattern

public String pattern()

simplify

public Constraint simplify()
If there are no constraints, this constraint may be removed. If there is a single requirement, this constraint may be transformed into another constraint. For example, if there is a single StringRequirement, this constraint will become a StringConstraint. There is no functional difference, but StringConstraint can be further optimized because it is more specific and has a nicer XML representation.

Overrides:
simplify in class Constraint
Returns:
the simplified constraint

subsumes

public boolean subsumes(Constraint other)
Description copied from class: Constraint
Checks is a constraint is weakly stricter than the other.

Overrides:
subsumes in class Constraint
Parameters:
other - constraint to compare against
Returns:
true if the other constraint is redundant

generalize

public List<Constraint> generalize()
Generalize by removing a subconstraint. The resulting TermConstrain may have zero requirements, so this should usually be followed with a call to simplify.

Specified by:
generalize in class Constraint
Returns:

deserializePattern

protected String deserializePattern(org.jdom.Element e)
Deserialize the sequence of term constraints in the XML element into a token-based pattern.

Overrides:
deserializePattern in class AbstractPatternConstraint
Returns:

buildPattern

protected static String buildPattern(List<TermConstraint.Requirement> requirements)
Build a pattern from the list of requirements.

Parameters:
requirements -
Returns:
the pattern expression

toXmlElement

public org.jdom.Element toXmlElement()
Overrides:
toXmlElement in class Constraint

toSubsequenceXmlElement

public org.jdom.Element toSubsequenceXmlElement()


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