jcreek.reasoning
Class EntityComparison

java.lang.Object
  extended byjcreek.reasoning.EntityComparison
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
CaseComparison, CaseComparisonNew, CaseFindingComparison, NumberComparison, PartitionComparison, StringComparison, SymbolComparison, URLComparison

public abstract class EntityComparison
extends java.lang.Object
implements java.lang.Comparable

An abstract class for comparison of two entities.

The similarity of two entities is measured by a strength. The strength is only computed if the comparison is comparable and the depth is above the threshold depth for comparison. The definition of comparable depends on whether the comparison is between entities or relations. Implementations of this class must therefore include a method for determining whether the comparison is comparable or not. They must include algorithms on how to compute the comparison strength.

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

Field Summary
static int ACTIVATED_STATUS
          The status of the comparison after activation
protected  double activationStrength
          The activation strength
static int EXPLAINED_STATUS
          The status of the comparison after explanation
protected  double explanationStrength
          The explanation strength
static int INITIAL_STATUS
          The status of the comparison before activation
protected static double INITIAL_STRENGTH
          The initial strength of the comparison
protected  Entity origin
          The origin concept
protected  Entity target
          The target concept
 
Constructor Summary
protected EntityComparison()
           
  EntityComparison(Entity origin, Entity target)
          Constructs a comparison between the origin concept and the target concept with given depth.
 
Method Summary
 void activate()
          Activates the comparison between the origin and target concepts.
static double addParallell(double s1, double s2)
          Formula used for calculate the strength of two explanations when they are parallell, i.e. either can be used.
static double addSerial(double s1, double s2)
          Formula used for calculate the strength of two explanations when they are serial, i.e. both must apply.
static boolean checkIsComparable(Entity e1, Entity e2)
          Tests if the two given entities are comparable.
 int compareTo(java.lang.Object a)
           
static EntityComparison createComparison(Entity origin, Entity target)
           
 void explain()
          Explains the comparison between the origin and target concepts.
 double getActivationStrength()
          Returns the activation strength of the comparison.
 double getExplanationStrength()
          Returns the explanation strength of the comparison.
 KnowledgeModel getKnowledgeModel()
          Returns the knowledge model of the origin concept.
 Entity getOrigin()
          Returns the origin concept of the comparison.
 int getPercentageStrength()
          Returns the strength of the comparison as a percentage int.
 int getStatus()
          Returns the status of the comparison.
 java.lang.String getStatusText()
          Returns the status of the comparison as a text string.
 double getStrength()
          Returns the strength of the comparison
 Entity getTarget()
          Returns the target concept of the comparison.
 boolean isActivated()
          Tests whether the comparison is activated.
 boolean isComparable()
          Tests if the entities in the comparison is comparable.
static boolean isComparable(Entity e1, Entity e2)
           
 boolean isCompletelyMatched()
          Tests whether the comparison is completely matched.
 boolean isExplained()
          Tests whether the comparison is explained.
 boolean isExplainMatched()
          Tests whether the comparison is explained matched.
 boolean isPartlyMatched()
          Tests whether the comparison is partly matched.
 boolean isUnmatched()
          Tests whether the comparison is unmatched.
 void reset()
          Resets the activation/explanation.
 java.lang.String shortExplanation()
          Gives a short textual representation (a sentence or so) describing the comparison.
 java.lang.String toString()
          Returns the string representation of the comparison
 SubModel toSubModel()
          Returns a submodel of the entities compared.
 void update()
           
protected abstract  double updateActivationStrength()
          Computes the activation strenght of the comparison.
protected abstract  double updateExplanationStrength()
          Updates the explanation strenght of the comparison.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INITIAL_STATUS

public static final int INITIAL_STATUS
The status of the comparison before activation

See Also:
Constant Field Values

ACTIVATED_STATUS

public static final int ACTIVATED_STATUS
The status of the comparison after activation

See Also:
Constant Field Values

EXPLAINED_STATUS

public static final int EXPLAINED_STATUS
The status of the comparison after explanation

See Also:
Constant Field Values

INITIAL_STRENGTH

protected static final double INITIAL_STRENGTH
The initial strength of the comparison

See Also:
Constant Field Values

origin

protected Entity origin
The origin concept


target

protected Entity target
The target concept


activationStrength

protected double activationStrength
The activation strength


explanationStrength

protected double explanationStrength
The explanation strength

Constructor Detail

EntityComparison

public EntityComparison(Entity origin,
                        Entity target)
Constructs a comparison between the origin concept and the target concept with given depth.

Parameters:
origin - the concept to compare from
target - the concept to compare to

EntityComparison

protected EntityComparison()
Method Detail

updateActivationStrength

protected abstract double updateActivationStrength()
Computes the activation strenght of the comparison. This method should not be called to often. Instead, call 'activate' and then 'getActivationStrength' When implemented by subclasses, this method should consist of the activation between the comparing concepts

Returns:
the activation strength of the comparison

updateExplanationStrength

protected abstract double updateExplanationStrength()
Updates the explanation strenght of the comparison. This method should not be called to often. Instead, call 'explain' and then 'getStrength' When implemented by subclasses, this method should consist of the explanation between the comparing concepts

Returns:
the explanation strength of the comparison

isComparable

public boolean isComparable()
Tests if the entities in the comparison is comparable.

Returns:
true if the comparison is comparable.

checkIsComparable

public static boolean checkIsComparable(Entity e1,
                                        Entity e2)
Tests if the two given entities are comparable.

Returns:
true if these entities are possible to compare.

isComparable

public static boolean isComparable(Entity e1,
                                   Entity e2)

reset

public void reset()
Resets the activation/explanation. i.e sets the status to INITIAL_STATUS and strength to INITIAL_STRENGTH.


update

public void update()

activate

public void activate()
Activates the comparison between the origin and target concepts. i.e sets the status to ACTIVATED_STATUS and computes the activation strength if the concepts are comparable and the depth is above threshold.

See Also:
isComparable()

isActivated

public boolean isActivated()
Tests whether the comparison is activated. The comparison is activated if the status is ACTIVATED_STATUS

Returns:
true if the comparison is activated

explain

public void explain()
Explains the comparison between the origin and target concepts. i.e sets the status to EXPLAINED_STATUS and computes the explanation strength if the concepts are comparable and the depth is above threshold.

See Also:
isComparable()

isExplained

public boolean isExplained()
Tests whether the comparison is explained. The comparison is activated if the status is EXPLAINED_STATUS

Returns:
true if the comparison is explained

getKnowledgeModel

public KnowledgeModel getKnowledgeModel()
Returns the knowledge model of the origin concept.

Returns:
the knowledge model of the origin concept.

getOrigin

public Entity getOrigin()
Returns the origin concept of the comparison.

Returns:
the origin concept of the comparison.

getTarget

public Entity getTarget()
Returns the target concept of the comparison.

Returns:
the target concept of the comparison.

getStatus

public int getStatus()
Returns the status of the comparison.

Returns:
the status of the comparison
See Also:
INITIAL_STATUS, ACTIVATED_STATUS, EXPLAINED_STATUS

getStatusText

public java.lang.String getStatusText()
Returns the status of the comparison as a text string.

Returns:
the status of the comparison as a text string
See Also:
INITIAL_STATUS, ACTIVATED_STATUS, EXPLAINED_STATUS

getActivationStrength

public double getActivationStrength()
Returns the activation strength of the comparison.


getExplanationStrength

public double getExplanationStrength()
Returns the explanation strength of the comparison.


toSubModel

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


getStrength

public double getStrength()
Returns the strength of the comparison

Returns:
the strenght of the comparison

getPercentageStrength

public int getPercentageStrength()
Returns the strength of the comparison as a percentage int.


addParallell

public static double addParallell(double s1,
                                  double s2)
Formula used for calculate the strength of two explanations when they are parallell, i.e. either can be used. Assumptions: 0 <= s1 and s2 <= 1.0 addParallell(s1, s2) == addParallell(s2, s1)


addSerial

public static double addSerial(double s1,
                               double s2)
Formula used for calculate the strength of two explanations when they are serial, i.e. both must apply. Assumptions: 0 <= s1 and s2 <= 1.0 addParallell(s1, s2) == addParallell(s2, s1)


isCompletelyMatched

public boolean isCompletelyMatched()
Tests whether the comparison is completely matched. The comparison is completely matched if the activation strength is 1 or more.

Returns:
true if the comparison is completely matched.

isPartlyMatched

public boolean isPartlyMatched()
Tests whether the comparison is partly matched. The comparison is partly matched if the activation strength is between 0 and 1.

Returns:
true if the comparison is partly matched.

isUnmatched

public boolean isUnmatched()
Tests whether the comparison is unmatched. The comparison is unmatched if the activation strength is 0 or less.

Returns:
true if the comparison is unmatched.

isExplainMatched

public boolean isExplainMatched()
Tests whether the comparison is explained matched. The comparison is explained matched if the explanation strength is above 0.

Returns:
true if the comparison is explained matched.

shortExplanation

public java.lang.String shortExplanation()
Gives a short textual representation (a sentence or so) describing the comparison.


toString

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

Returns:
the string representation of the comparison

createComparison

public static EntityComparison createComparison(Entity origin,
                                                Entity target)

compareTo

public int compareTo(java.lang.Object a)
Specified by:
compareTo in interface java.lang.Comparable


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