edu.washington.cs.knowitall.rule
Class Rule

java.lang.Object
  extended by edu.washington.cs.knowitall.rule.Rule
All Implemented Interfaces:
Serializable

public class Rule
extends Object
implements Serializable

An expression that represents a mapping from extractions to ontological relations. When evaluated against an extraction, a rule may result in an ontological relation.

Author:
schmmd
See Also:
Serialized Form

Field Summary
 edu.washington.cs.knowitall.commonlib.ArraySet<Constraint> constraints
           
 OntologicalForm form
           
static org.slf4j.Logger logger
           
 Rule parent
           
 
Constructor Summary
Rule(OntologicalForm ontology)
          Constructs a new rule that maps onto the specified ontological form without additional constraints.
Rule(OntologicalForm ontology, Collection<Constraint> additionalConstraints)
           
Rule(Rule parent, OntologicalForm ontology, Collection<Constraint> additionalConstraints)
          Constructs a new rule that maps onto the specified ontological form when all constraints are met.
 
Method Summary
 OntologicalRelation apply(RelationExtraction extraction)
          Apply this rule to the supplied extraction and return the resulting ontological relation.
 Iterable<Constraint> argumentConstraints()
          Retrieve the constraints that are in the arguments.
 Rule baseRule()
          Recursively finds the highest parent of this rule.
 boolean check(Annotation annotation)
          Checks that this rule yields the supplied annotation when applied to the appropriate annotation's extraction.
 boolean check(RelationExtraction extraction)
          Checks that this rule applied to the supplied extraction yields an ontological relation.
 Iterable<Constraint> constraints(ExtractionPart part)
          Retrieve the constraints on the specified relation part.
 int constraintSize()
          Return the size of the constraints.
 String constraintsToMultilineString()
           
 boolean equals(Object other)
           
 Iterable<Annotation> filterAnnotations(List<Annotation> annotations)
          Filters the annotations by those that check against this rule.
 Iterable<RelationExtraction> filterExtractions(Iterable<RelationExtraction> extractions)
           
static List<Rule> fromXmlDocument(org.jdom.Document document)
           
static Rule fromXmlElement(org.jdom.Element e)
           
 List<Rule> generalize()
          Returns a list of all the rules that are generalized by removing a single constraint (reducing the constraint size by 1).
 int hashCode()
           
static void main(String[] args)
           
 Rule simplify()
          Simplify the rule by removing constraints that are subsumed by another constraint or an argument constraint.
 Rule simplifySubsumptions()
           
 void test(com.google.common.collect.Multimap<Sentence,Annotation> annotationMap)
           
 String toMultilineString()
           
 String toMultilineXMLString()
          Pretty formatted XML output.
 String toString()
          Returns a single line XML representation of this rule.
static org.jdom.Document toXmlDocument(Iterable<Rule> rules)
           
 org.jdom.Element toXmlElement()
           
 String toXMLString()
          XML output.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

public static final org.slf4j.Logger logger

constraints

public final edu.washington.cs.knowitall.commonlib.ArraySet<Constraint> constraints

form

public final OntologicalForm form

parent

public final Rule parent
Constructor Detail

Rule

public Rule(Rule parent,
            OntologicalForm ontology,
            Collection<Constraint> additionalConstraints)
Constructs a new rule that maps onto the specified ontological form when all constraints are met.

Parameters:
ontology -
additionalConstraints -

Rule

public Rule(OntologicalForm ontology,
            Collection<Constraint> additionalConstraints)

Rule

public Rule(OntologicalForm ontology)
Constructs a new rule that maps onto the specified ontological form without additional constraints.

Parameters:
ontology -
Method Detail

toString

public String toString()
Returns a single line XML representation of this rule.

Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

toMultilineString

public String toMultilineString()

constraintsToMultilineString

public String constraintsToMultilineString()

toMultilineXMLString

public String toMultilineXMLString()
Pretty formatted XML output.

Returns:

toXMLString

public String toXMLString()
XML output.

Returns:

baseRule

public Rule baseRule()
Recursively finds the highest parent of this rule.

Returns:

constraints

public Iterable<Constraint> constraints(ExtractionPart part)
Retrieve the constraints on the specified relation part.

Parameters:
part -
Returns:
matching constraints

argumentConstraints

public Iterable<Constraint> argumentConstraints()
Retrieve the constraints that are in the arguments.

Returns:

constraintSize

public int constraintSize()
Return the size of the constraints. Note that this is different than the count of the constraints, as some constraints may have multiple sub-constraints.

Returns:

check

public boolean check(Annotation annotation)
Checks that this rule yields the supplied annotation when applied to the appropriate annotation's extraction.


check

public boolean check(RelationExtraction extraction)
Checks that this rule applied to the supplied extraction yields an ontological relation.

Parameters:
extraction -
Returns:

test

public void test(com.google.common.collect.Multimap<Sentence,Annotation> annotationMap)

filterAnnotations

public Iterable<Annotation> filterAnnotations(List<Annotation> annotations)
Filters the annotations by those that check against this rule.

Parameters:
annotations -
Returns:

filterExtractions

public Iterable<RelationExtraction> filterExtractions(Iterable<RelationExtraction> extractions)

apply

public OntologicalRelation apply(RelationExtraction extraction)
Apply this rule to the supplied extraction and return the resulting ontological relation.

Parameters:
extraction -
Returns:
the ontological relation or null if none

simplifySubsumptions

public Rule simplifySubsumptions()

simplify

public Rule simplify()
Simplify the rule by removing constraints that are subsumed by another constraint or an argument constraint.

Returns:

generalize

public List<Rule> generalize()
Returns a list of all the rules that are generalized by removing a single constraint (reducing the constraint size by 1). The resulting list may contain duplicates.

Returns:

fromXmlDocument

public static List<Rule> fromXmlDocument(org.jdom.Document document)

toXmlDocument

public static org.jdom.Document toXmlDocument(Iterable<Rule> rules)

fromXmlElement

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

toXmlElement

public org.jdom.Element toXmlElement()

main

public static void main(String[] args)
                 throws org.jdom.JDOMException,
                        IOException
Throws:
org.jdom.JDOMException
IOException


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