jcreek.representation
Class RelationType

java.lang.Object
  extended byjcreek.representation.Entity
      extended byjcreek.representation.EntityType
          extended byjcreek.representation.RelationType
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class RelationType
extends EntityType

Title: RelationType

Description: Represents a type of relation.

Version:
1.0
Author:
Frode Sørmo

Constructor Summary
RelationType(Entity relationTypeEntity)
          This constructor does not create a new relation type in the model, but merely creates a new RelationType object to encapsulate an entity that represents a RelationType already.
RelationType(KnowledgeModel km, RelationType superclass, java.lang.String name, java.lang.String description, double defaultExplanationStrength)
          Creates a new relation type which is its own inverse type (i.e. it is bidirectional).
RelationType(KnowledgeModel km, RelationType superclass, java.lang.String relationName, java.lang.String description, double defaultExplanationStrength, java.lang.String inverseName, java.lang.String inverseDesc, double inverseDefaultExplanationStrength)
          Creates a new relation type with an inverse type.
RelationType(KnowledgeModel km, RelationType superclass, java.lang.String relationName, java.lang.String description, java.lang.String inverseName, java.lang.String inverseDesc, double defaultExplanationStrength)
          Creates a new relation type with an inverse type, where the default explanation strength of both are the same.
 
Method Summary
 double getExplanationStrength()
          Returns the default explanation strength of new relations created of this type.
 Relation[] getInstances()
          Returns all instances of this relation type and all of its subclasses.
 java.lang.String getInverseName()
          Returns the name of the inverse relation-type.
 RelationType getInverseType()
          Returns the RelationType object for the inverse of this type.
 java.lang.String getNaturalInverseName()
          Returns the natural name (a verb phrase) of the inverse relation-type.
 java.lang.String getNaturalName()
          Returns a complete verb phrase useable for natural language generatation.
 Entity getValueType()
          Returns the value type of this relation type.
 boolean hasInverseType()
          Returns true if this relation type has an inverse.
static boolean matches(Entity ent)
          An Entity is a RelationType if and only if and only if it is an (indirect) subclass of the Relation object.
 Relation newInstance(Entity from, Entity to)
          Creates a new relation of the type represented by this RelationType between the two supplied relations.
 Relation newInstance(Entity from, Entity to, double explanationStrength)
          Creates a new relation of the type represented by this RelationType between the two supplied relations.
 void remove()
          Removes this relation type.
 void setExplanationStrength(double strength)
          Sets the default explanation strength of new relations created of this relation type.
 void setNaturalName(java.lang.String name)
          Sets the natural name of this RelationType.
 void setValueType(Entity type)
          Sets the value type of this relation type.
 
Methods inherited from class jcreek.representation.Entity
addConstraint, addRelation, addRelation, addRelation, addRelation, addRelation, addRelation, clone, compareTo, equals, getAllSubclasses, getAllSubclassesCollection, getAllSuperclasses, getAllSuperclassesCollection, getConstraints, getCreationTime, getCurrentPartition, getDescription, getEntityData, getEntityObject, getFrameString, getID, getImmediateSubclasses, getImmediateSubclassesCollection, getImmediateSuperclasses, getImmediateSuperclassesCollection, getInheritedConstraints, getKnowledgeModel, getLocalConstraints, getLocalRelation, getLocalRelation, getLocalRelation, getLocalRelation, getLocalRelation, getLocalRelation, getLocalRelations, getLocalRelations, getLocalRelations, getLocalRelations, getLocalRelations, getName, getRelation, getRelation, getRelation, getRelation, getRelationNames, getRelations, getRelations, getRelations, getRelations, getRelations, getRelations, getRelations, getRelationTypes, getValueString, hasEntityObject, hashCode, isAssignableFrom, removeConstraint, removeEntityData, setDescription, setEntityObject, setName, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RelationType

public RelationType(KnowledgeModel km,
                    RelationType superclass,
                    java.lang.String name,
                    java.lang.String description,
                    double defaultExplanationStrength)
             throws NameAlreadyExistException
Creates a new relation type which is its own inverse type (i.e. it is bidirectional).

Parameters:
km - The KnowledgeModel this RelationType is a part of.
superclass - The superclass of the new RelationType.
name - The name of the new RelationType.
description - The description of the new RelationType.
defaultExplanationStrength - The explanation strength used for new relations of this type.

RelationType

public RelationType(KnowledgeModel km,
                    RelationType superclass,
                    java.lang.String relationName,
                    java.lang.String description,
                    double defaultExplanationStrength,
                    java.lang.String inverseName,
                    java.lang.String inverseDesc,
                    double inverseDefaultExplanationStrength)
             throws NameAlreadyExistException
Creates a new relation type with an inverse type.

Parameters:
km - The KnowledgeModel this RelationType is a part of.
superclass - The superclass of the new RelationType.
description - The description of the new RelationType.
defaultExplanationStrength - The explanation strength used when creating new relations of this type.
inverseName - The name of the inverse of this RelationType.
inverseDesc - The description of the inverse of this RelationType.
inverseDefaultExplanationStrength - The explanation strength used for new relations of the inverse type.

RelationType

public RelationType(KnowledgeModel km,
                    RelationType superclass,
                    java.lang.String relationName,
                    java.lang.String description,
                    java.lang.String inverseName,
                    java.lang.String inverseDesc,
                    double defaultExplanationStrength)
             throws NameAlreadyExistException
Creates a new relation type with an inverse type, where the default explanation strength of both are the same.

Parameters:
km - The KnowledgeModel this RelationType is a part of.
superclass - The superclass of the new RelationType.
description - The description of the new RelationType.
inverseName - The name of the inverse of this RelationType.
inverseDesc - The description of the inverse of this RelationType.
defaultExplanationStrength - The explanation strength used for new relations of this type and the inverse type.

RelationType

public RelationType(Entity relationTypeEntity)
             throws EntityTypeNotMatchedException
This constructor does not create a new relation type in the model, but merely creates a new RelationType object to encapsulate an entity that represents a RelationType already.

Method Detail

getInverseType

public RelationType getInverseType()
Returns the RelationType object for the inverse of this type. This is found by following the "has inverse" relation. If there is no such relation, it is assumed that this type has no inverse (is bidirectional) and thus this RelationType is returned.


hasInverseType

public boolean hasInverseType()
Returns true if this relation type has an inverse.


getNaturalName

public java.lang.String getNaturalName()
Returns a complete verb phrase useable for natural language generatation. If a natural name is not defined, the name of the entity is returned.


getInverseName

public java.lang.String getInverseName()
Returns the name of the inverse relation-type.


getNaturalInverseName

public java.lang.String getNaturalInverseName()
Returns the natural name (a verb phrase) of the inverse relation-type.


setNaturalName

public void setNaturalName(java.lang.String name)
Sets the natural name of this RelationType. This name should be a complete verb phrase. So for instance while "color of" is an acceptable relation type name, the natural language name should also include the auxilry verb and determiner required in this case, i.e. "is the color of". To test, place a noun before and after the phrase and see if the sentence fragment sounds natural.

Parameters:
name - The natural name.

setExplanationStrength

public void setExplanationStrength(double strength)
Sets the default explanation strength of new relations created of this relation type. This strength must be between 1.0 and 0.0. If it is not, it is rounded to the closest value in the range.

Parameters:
strength - A double in the range [0.0, 1.0] that is the new default explanation strength.

getExplanationStrength

public double getExplanationStrength()
Returns the default explanation strength of new relations created of this type.


getValueType

public Entity getValueType()
Returns the value type of this relation type. The meaning of value type is that relations of this relation type is supposed to have a value that is an instance or subclass of the entity representing the value.

Returns:
The value type entity.

setValueType

public void setValueType(Entity type)
Sets the value type of this relation type. The meaning of value type is that relations of this relation type is supposed to have a value that is an instance or subclass of the entity representing the value.


remove

public void remove()
Removes this relation type. This will also remove the inverse relation and all instances of this relation and the inverse relation.

Overrides:
remove in class Entity

getInstances

public Relation[] getInstances()
Returns all instances of this relation type and all of its subclasses.


newInstance

public Relation newInstance(Entity from,
                            Entity to)
Creates a new relation of the type represented by this RelationType between the two supplied relations.

Parameters:
from - The origin entity of the new relation.
to - The value entity of the new relation.

newInstance

public Relation newInstance(Entity from,
                            Entity to,
                            double explanationStrength)
Creates a new relation of the type represented by this RelationType between the two supplied relations.

Parameters:
from - The origin entity of the new relation.
to - The value entity of the new relation.
explanationStrength - The strength of the new relation.

matches

public static boolean matches(Entity ent)
An Entity is a RelationType if and only if and only if it is an (indirect) subclass of the Relation object.



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