jcreek.reasoning
Class CaseComparison

java.lang.Object
  extended byjcreek.reasoning.EntityComparison
      extended byjcreek.reasoning.CaseComparison
All Implemented Interfaces:
java.lang.Comparable

public class CaseComparison
extends EntityComparison

A comparison between two cases.

The comparison is comparable if the entities have one parent in common. Two entities are compared by comparing the relations of the entities, i.e. by creating relation comparisons of every possible combination, (followed by activation and explanation) and computing the strength.

Version:
1.1
Author:
Ellen Lippe, modified by Frode Sørmo of NTNU 2001-2002

Field Summary
protected  java.util.Vector comparisons
          The list of all finding comparisons
protected  java.util.Hashtable findingToComparisons
          Hashtable of finding-relation => comparisons involving that finding-relation.
protected  double relevanceStrengthSum
          The sum of all the relvance strengths of the target cases findings.
static double UNMATCHED_ORIGIN_PENALTY
          Constant that gives the maximum penalty for unmatched origin findings.
protected  java.util.Vector unmatchedOrigin
          List of unmatched target relations.
protected  java.util.Vector unmatchedTarget
          List of unmatched target relations.
 
Fields inherited from class jcreek.reasoning.EntityComparison
ACTIVATED_STATUS, activationStrength, EXPLAINED_STATUS, explanationStrength, INITIAL_STATUS, INITIAL_STRENGTH, origin, target
 
Constructor Summary
CaseComparison(Entity origin, Entity target)
          Creates a new comparison between the origin case and the target case with default depth depth.
 
Method Summary
 boolean findingsComparable(Relation origin, Relation target)
           
static Entity[] getCompleteFindingList(Case[] cases)
           
 CaseFindingComparison[] getCompletelyMatchedComparisons()
          Returns the list of completely matched finding comparisons.
 CaseFindingComparison[] getExplainedMatchedComparisons()
          Returns the list of explained matched finding comparisons.
 CaseFindingComparison[] getFindingComparisons()
          Returns the list of all finding comparisons.
 Relation[] getOriginRelations()
          Returns all the relations of origin entity of the comparison.
 Relation[] getOriginRelations(RelationType relationClass)
          Returns all the relations of the given type of origin entity of the comparison.
 CaseFindingComparison[] getPartlyMatchedComparisons()
          Returns the list of partly matched finding comparisons.
static double getRelevanceFactor(Relation finding)
           
 double getRelevanceFactorSum()
          Returns the sum of the relevance factors of all findings in the target case.
 double getStrength()
          Returns the total strength of the case comparison, defined as: activation strength+explanation strength-penalty for unmatched origin findings.
 Relation[] getTargetRelations()
          Returns all the relations of the target entity of the comparison.
 Relation[] getTargetRelations(RelationType relationClass)
          Returns all the relations of the given type of target entity of the comparison.
 CaseFindingComparison[] getUnmatchedComparisons()
          Returns the list of unmatched finding comparisons.
 Relation[] getUnmatchedOriginRelations()
          Return the finding-relations in the origin case that are currently not matched with any relations in the target case.
 double getUnmatchedPenalty()
          Returns the penalty applied to the score for a case for each unmatched origin case finding.
 Relation[] getUnmatchedTargetRelations()
          Return the finding-relations in the target case that are currently not matched with any relations in the origin case.
 boolean hasFindings()
           
 void reset()
          Resets the comparison.
 java.lang.String toString()
          Returns the string representation of the entity comparison
 SubModel toSubModel()
          Returns a submodel of the entities compared.
protected  double updateActivationStrength()
          Activates the comparison and returns the activation strenght.
protected  double updateExplanationStrength()
          Explains the comparison and returns the explanation strenght.
 
Methods inherited from class jcreek.reasoning.EntityComparison
activate, addParallell, addSerial, checkIsComparable, compareTo, createComparison, explain, getActivationStrength, getExplanationStrength, getKnowledgeModel, getOrigin, getPercentageStrength, getStatus, getStatusText, getTarget, isActivated, isComparable, isComparable, isCompletelyMatched, isExplained, isExplainMatched, isPartlyMatched, isUnmatched, shortExplanation, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

comparisons

protected java.util.Vector comparisons
The list of all finding comparisons


findingToComparisons

protected java.util.Hashtable findingToComparisons
Hashtable of finding-relation => comparisons involving that finding-relation.


unmatchedTarget

protected java.util.Vector unmatchedTarget
List of unmatched target relations.


unmatchedOrigin

protected java.util.Vector unmatchedOrigin
List of unmatched target relations.


relevanceStrengthSum

protected double relevanceStrengthSum
The sum of all the relvance strengths of the target cases findings.


UNMATCHED_ORIGIN_PENALTY

public static final double UNMATCHED_ORIGIN_PENALTY
Constant that gives the maximum penalty for unmatched origin findings.

See Also:
Constant Field Values
Constructor Detail

CaseComparison

public CaseComparison(Entity origin,
                      Entity target)
Creates a new comparison between the origin case and the target case with default depth depth. This consists of initializing the activation comparison list and the explanation comparison list with the origin and target relations, ready to be activated or explained.

Parameters:
origin - the case to compare from
target - the case to compare to
See Also:
DEFAULT_DEPTH
Method Detail

getRelevanceFactor

public static double getRelevanceFactor(Relation finding)

reset

public void reset()
Resets the comparison.

Overrides:
reset in class EntityComparison

findingsComparable

public boolean findingsComparable(Relation origin,
                                  Relation target)

updateActivationStrength

protected double updateActivationStrength()
Activates the comparison and returns the activation strenght. i.e. matches the activation comparison list to put all relations in correct lists (matched or unmatched) and to obtain the relation comparisons, and then compute the strength. This method should not be called to often. Instead, call 'activate' once and then 'getStrength' each time you need the activation strength.

Specified by:
updateActivationStrength in class EntityComparison
Returns:
the activation strength of the comparison

updateExplanationStrength

protected double updateExplanationStrength()
Explains the comparison and returns the explanation strenght. i.e. matches the explanation comparison list to put all relations in correct lists (matched or unmatched) and to obtain the relation comparisons, and then compute the strength. If the comparison is not activated already, this will be done first. This method should not be called to often. Instead, call 'explain' once and then 'getStrength' each time you need the explanation strength.

Specified by:
updateExplanationStrength in class EntityComparison
Returns:
the explanation strength of the comparison

getOriginRelations

public Relation[] getOriginRelations()
Returns all the relations of origin entity of the comparison.

Returns:
the relations of the origin entity of the comparison.

getOriginRelations

public Relation[] getOriginRelations(RelationType relationClass)
Returns all the relations of the given type of origin entity of the comparison.

Parameters:
relationClass - the class of relations to return for the origin entity.
Returns:
the relations of the given type origin entity of the comparison.

getTargetRelations

public Relation[] getTargetRelations()
Returns all the relations of the target entity of the comparison.

Returns:
the relations of the target entity of the comparison.

getTargetRelations

public Relation[] getTargetRelations(RelationType relationClass)
Returns all the relations of the given type of target entity of the comparison.

Parameters:
relationClass - the class of relations to return for the target entity.
Returns:
the relations of the given type target entity of the comparison.

getFindingComparisons

public CaseFindingComparison[] getFindingComparisons()
Returns the list of all finding comparisons.

Returns:
list of all finding comparisons

getCompletelyMatchedComparisons

public CaseFindingComparison[] getCompletelyMatchedComparisons()
Returns the list of completely matched finding comparisons.

Returns:
list of completely matched finding comparisons

getPartlyMatchedComparisons

public CaseFindingComparison[] getPartlyMatchedComparisons()
Returns the list of partly matched finding comparisons.

Returns:
list of partly matched finding comparisons

getUnmatchedComparisons

public CaseFindingComparison[] getUnmatchedComparisons()
Returns the list of unmatched finding comparisons.

Returns:
list of unmatched finding comparisons

getUnmatchedOriginRelations

public Relation[] getUnmatchedOriginRelations()
Return the finding-relations in the origin case that are currently not matched with any relations in the target case.


getUnmatchedTargetRelations

public Relation[] getUnmatchedTargetRelations()
Return the finding-relations in the target case that are currently not matched with any relations in the origin case.


getRelevanceFactorSum

public double getRelevanceFactorSum()
Returns the sum of the relevance factors of all findings in the target case. This can be used to normalize the relative relevance of the findings.

Returns:
double

getStrength

public double getStrength()
Returns the total strength of the case comparison, defined as: activation strength+explanation strength-penalty for unmatched origin findings.

Overrides:
getStrength in class EntityComparison
Returns:
double

getUnmatchedPenalty

public double getUnmatchedPenalty()
Returns the penalty applied to the score for a case for each unmatched origin case finding.

Returns:
double

getExplainedMatchedComparisons

public CaseFindingComparison[] getExplainedMatchedComparisons()
Returns the list of explained matched finding comparisons.

Returns:
list of explained matched finding comparisons

hasFindings

public boolean hasFindings()

toString

public java.lang.String toString()
Returns the string representation of the entity comparison

Overrides:
toString in class EntityComparison
Returns:
the string representation of the entity comparison

toSubModel

public SubModel toSubModel()
Returns a submodel of the entities compared.

Overrides:
toSubModel in class EntityComparison

getCompleteFindingList

public static Entity[] getCompleteFindingList(Case[] cases)


Created at IDI, NTNU by the Artificial Intelligence and Learning group