edu.byu.deg.ontos.heuristic
Class FunctionalGroupHeuristic

java.lang.Object
  extended byedu.byu.deg.ontos.MappingHeuristic
      extended byedu.byu.deg.ontos.heuristic.FunctionalGroupHeuristic

public class FunctionalGroupHeuristic
extends MappingHeuristic

A mapping heuristic that generates a relationship based on a relationship set connection that qualifies as a functional group in the traversal of the ontology structure.


Field Summary
 
Fields inherited from class edu.byu.deg.ontos.MappingHeuristic
ACCEPTED_MATCH, connComparer, ontIndex, PROPOSED_MATCH, REJECTED_MATCH
 
Constructor Summary
FunctionalGroupHeuristic()
          Creates a new instance of FunctionalGroupHeuristic
FunctionalGroupHeuristic(ExtractionOntologyIndex idx)
          Creates a new instance of FunctionalGroupHeuristic and initializes it with an indexed ontology.
 
Method Summary
protected  int compareRelSets(edu.byu.deg.osmx.OSMXRelSetConnectionType r1, edu.byu.deg.osmx.OSMXRelSetConnectionType r2, MatchingContext ctxt)
          Defines a total order on a set of relationship set connections by determining, for a pair of such connections, which should precede the other in a sorted list.
protected  MatchingContext findBestSubContext(edu.byu.deg.osmx.OSMXRelSetConnectionType conn, MatchingContext ctxt)
          Determines the likely outer boundaries of the functional group from the given context and returns the result as a matching context.
protected  edu.byu.deg.osmx.OSMXRelationshipType inferRelationship(edu.byu.deg.osmx.OSMXRelSetConnectionType primaryConn, MatchingContext ctxt, Set visitedRelSets)
          Generates a single relationship from the given context.
 Set inferRelationships(edu.byu.deg.osmx.OSMXRelSetConnectionType primaryConn, MatchingContext ctxt, Set visitedRelSets)
          The main algorithm for this heuristic.
protected  MatchingContext[] subdivideContext(MatchingContext ctxt)
          Divides the given context into multiple matching contexts whose boundaries should approximate the contextual boundaries of the individual objects to be generated for the functional group.
 
Methods inherited from class edu.byu.deg.ontos.MappingHeuristic
addObject, addRelationship, bindObject, getOntologyIndex, getOntologyIndex, setOntologyIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionalGroupHeuristic

public FunctionalGroupHeuristic()
Creates a new instance of FunctionalGroupHeuristic


FunctionalGroupHeuristic

public FunctionalGroupHeuristic(ExtractionOntologyIndex idx)
Creates a new instance of FunctionalGroupHeuristic and initializes it with an indexed ontology.

Parameters:
idx - The index for the ontology used by this heuristic.
Method Detail

inferRelationships

public Set inferRelationships(edu.byu.deg.osmx.OSMXRelSetConnectionType primaryConn,
                              MatchingContext ctxt,
                              Set visitedRelSets)
The main algorithm for this heuristic. The method generates relationships from the context by greedily invoking ContextualHeuristic recursively until no more objects are produced. A relationship is created for each object returned by ContextualHeuristic, and the set of relationships is returned.

Parameters:
primaryConn - The relationship set connection from which the traversal is originating; in other words, the "side" of the relationship set that the invoking code acted upon to invoke this heuristic. This parameter identifies both the relationship set for which the relationships should be generated, as well as in which direction to continue the recursion.
ctxt - The matching context from which relationships should be generated.
visitedRelSets - A collection of relationship sets previously visited during the recursion; allows us to avoid infinite recursion.
Returns:
A Set of Relationship elements.

inferRelationship

protected edu.byu.deg.osmx.OSMXRelationshipType inferRelationship(edu.byu.deg.osmx.OSMXRelSetConnectionType primaryConn,
                                                                  MatchingContext ctxt,
                                                                  Set visitedRelSets)
Generates a single relationship from the given context.

Parameters:
primaryConn - The connection that identifies the relationship set for which the relationship should be generated. It also indicates from which direction the ontology traversal is proceeding, so that infinite recursion can be avoided.
ctxt - The matching context from which the relationship is to be derived.
visitedRelSets - A set of previously visited relationship sets, used to remember where the traversal has already been performed so that infinite recursion can be avoided.
Returns:
The generated relationship, or null if none could be successfully generated from the context.

compareRelSets

protected int compareRelSets(edu.byu.deg.osmx.OSMXRelSetConnectionType r1,
                             edu.byu.deg.osmx.OSMXRelSetConnectionType r2,
                             MatchingContext ctxt)
Defines a total order on a set of relationship set connections by determining, for a pair of such connections, which should precede the other in a sorted list.

Parameters:
r1 - The first relationship set connection to compare.
r2 - The second relationship set connection to compare.
ctxt - The current matching context, which provides information useful in assessing which connection should precede the other.
Returns:
-1 if the first connection should precede the second; or 1 if the second should precede the first. This function does not return 0 unless r1 == r2. This method bases the order only on a dictionary ordering of the IDs of the relationship sets being compared.

findBestSubContext

protected MatchingContext findBestSubContext(edu.byu.deg.osmx.OSMXRelSetConnectionType conn,
                                             MatchingContext ctxt)
Determines the likely outer boundaries of the functional group from the given context and returns the result as a matching context.

Parameters:
conn - The connection that identifies the functional group.
ctxt - The context from which to derive the functional group context.
Returns:
A matching context that is guaranteed to be a subset of the given context. The method currently returns the same context as is passed in, effectively rendering the method a no-op.

subdivideContext

protected MatchingContext[] subdivideContext(MatchingContext ctxt)
Divides the given context into multiple matching contexts whose boundaries should approximate the contextual boundaries of the individual objects to be generated for the functional group. In other words, if the original context would cause multiple objects to be generated, it would be divided into that number of sub-contexts, from each of which an object may be derived.

Parameters:
ctxt - The context to subdivide.
Returns:
An array of matching contexts, each corresponding to an object expected to be generated in the recursive invocation of ContextualHeuristic. Currently this method is not implemented and will throw UnsupportedOperationException if called.