public class CASAOntology extends Object implements Ontology
(declRelation rel) (declRelation rel :base rel { :inverse|:transitive|:reflexive|:symmetric | :assignable | :domain-constraint constraint | :range-constraint constraint | :uses rel }*) (declType type) (declIndividual ind) (declMaplet rel type {type}|({type}*)) (constraint type? {:type-only|:individual-only}?) (rel id id) (rel id) (describe '{id|rel}) (declSlot id slot { :type type | :value val | :uses rel }*) (typeExp) (typeExp id) (slot id slot)where
To facilitate the type lattice, there are 8 primitive relations and one type that pre-defined:
(deftboxrel "isa-parent" :domain-constraint (constraint :type type) :range-constraint (constraint :type type)) (deftboxrel "isa-ancestor" :base isa-parent :transitive) (deftboxrel "isa" :base isa-ancestor :transitive :reflexive ) (deftboxrel "isa-child" :base isa-parent :inverse :assignable) (deftboxrel "isa-decendant" :base isa-child :inverse :transitive ) (declRelation "isequal" :transitive :reflexive :symmetric :assignable) (declType "TOP")
Copyright: Copyright 2003-2014,Knowledge Science Group, University of Calgary. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The Knowledge Science Group makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
Modifier and Type | Field and Description |
---|---|
(package private) static Map<String,CASAOntology> |
allOntologies
Records all "public" (within the process) ontologies.
|
(package private) static Type |
bottom
A primitive type
|
static String |
BOTTOM
The name of the primitive type bottom
|
static String |
DEFAULT_FILE_EXTENSION |
private String |
filePath
The filename that this ontology was loaded from.
|
(package private) static ConcreteRelation |
instanceOf
A primitive relation
|
static String |
INSTANCEOF
The name of the primitive relation isequal
|
(package private) static ConcreteRelation |
isa
A primitive relation
|
static String |
ISA
The name of the primitive relation isa
|
(package private) static ConcreteRelation |
isaAncestor
A primitive relation
|
static String |
ISAANCESTOR
The name of the primitive relation isaAncestor
|
(package private) static ConcreteRelation |
isaChild
A primitive relation
|
static String |
ISACHILD
The name of the primitive relation isaChild
|
(package private) static ConcreteRelation |
isaDescendant
A primitive relation
|
static String |
ISADESCENDANT
The name of the primitive relation isaDescendant
|
(package private) static ConcreteRelation |
isaParent
A primitive relation
|
static String |
ISAPARENT
The name of the primitive relation isaParent
|
(package private) static ConcreteRelation |
isequal
A primitive relation
|
static String |
ISEQUAL
The name of the primitive relation isequal
|
private String |
name
The name of the ontology.
|
(package private) static String |
PRIMITIVE_ONTOLOGY
The name of the primitive ontology
|
(package private) static CASAOntology |
primitiveOntology
The primitive ontology
|
(package private) static ConcreteRelation |
properInstanceOf
A primitive relation
|
static String |
PROPERINSTANCEOF
The name of the primitive relation isaDescendant
|
(package private) HierarchicalDictionary<Relation> |
relations
A specialized
HierarchicalDictionary used to contain relation objects in this ontology. |
(package private) List<CASAOntology> |
superOntologies
The list of the super ontologies of this ontology
|
(package private) HierarchicalDictionary<BaseType> |
tBox
A specialized
HierarchicalDictionary used to contain type objects in this ontology. |
(package private) static Type |
top
A primitive type
|
static String |
TOP
The name of the primitive type top
|
ONT__ASSERT, ONT__DESCRIBE, ONT__GET, ONT__GET_RESIDENT, ONT__IMPORT, ONT__INDIVIDUAL, ONT__IS_INDIVIDUAL, ONT__IS_OBJECT, ONT__IS_TYPE, ONT__RELATED_TO, ONT__RELATION, ONT__SET_DEFAULT, ONT__TYPE, ONTOLOGY
Modifier | Constructor and Description |
---|---|
private |
CASAOntology(String name,
CASAOntology... superOntologies)
Instantiates a new ontology with parents specified by superOntologies.
|
Modifier and Type | Method and Description |
---|---|
int |
add(String description)
CASAOntolgy does not implement this method, and throws an
IncompatableTypeHierarchiesException . |
void |
addIndividual(String name,
String... parents) |
void |
addIndividual(String name,
String parent) |
void |
addSuperOntologies(Ontology... parentOntologies) |
void |
addSuperOntologies(String... superOntologyNames) |
void |
addType(String name,
String... parents)
Adds an isa-parent relationship between name and each of the parents to the ontology.
|
void |
addType(String name,
String parent)
Adds an isa-parent relationship between name and parent to the ontology.
|
private int |
appendMapletDecl(StringBuffer b,
BaseType t,
Relation rel) |
private boolean |
canBeBase(Set<Relation.Property> properties) |
BaseType |
declIndividual(String name)
Adds a new individual to this ontology.
|
protected void |
declMaplet(Relation relation,
BaseType domain,
BaseType range)
Adds a new pair in relationName to this ontology.
|
void |
declMaplet(Relation relation,
String domainName,
String rangeName)
Adds a new pair in relationName to this ontology.
|
void |
declMaplet(String relationName,
String domainName,
String rangeName)
Adds a new pair in relationName to this ontology.
|
ConcreteRelation |
declRelation(String name,
ConcreteRelation basedOn,
Relation.Property[] properties,
ConstraintSimple domConstraint,
ConstraintSimple ranConstraint,
Object... otherParams)
Convenience method that calls
#declRelation(String, ConcreteRelation, Property[], ConstraintSimple, ConstraintSimple, Object...) after converting
the properties parameter. |
ConcreteRelation |
declRelation(String name,
ConcreteRelation basedOn,
Set<Relation.Property> properties,
Constraint domConstraint,
Constraint ranConstraint,
Object... otherParams)
Create and record a new relation in this ontology.
|
void |
declRelation(String name,
String basedOn,
Set<Relation.Property> properties,
Constraint domConstraint,
Constraint ranConstraint,
Object... otherParams) |
BaseType |
declType(String name)
Adds a new type to this ontology.
|
String |
describe(BaseType type)
This method is not fully implemented in this implementation
|
String |
describe(String name)
This method is not fully implemented in this implementation
|
private String |
describe2(Type theType,
TreeSet<Type> doneTypes,
TreeSet<String> doneRels)
This method is not fully implemented in this implementation
|
String |
describeIndividual(String type) |
private String |
describeRel(Relation relation,
TreeSet<String> doneRels)
This method is not fully implemented in this implementation
|
String |
describeRelation(String relation) |
String |
describeType(String type) |
Status |
extendWith(String spec)
Not implemented.
|
String |
getDefaultFileExtension() |
String |
getName() |
static CASAOntology |
getOntology(String name)
Find or read in a CASAOntology.
|
Relation |
getRelation(String name)
Retrieves the relation object based on the name.
|
static String[] |
getResident() |
BaseType |
getType(String name)
Retrieves the type object based on the name.
|
boolean |
instanceOf(String child,
String parent) |
Set<String> |
isa(String child)
Finals all ancestors of child.
|
boolean |
isa(String child,
String parent)
Shortcut for the (isa child parent) lisp operator, or this.relatedTo(isa,child,parent).
|
Set<String> |
isAncestor(String child) |
private boolean |
isAssignable(Set<Relation.Property> properties) |
Set<String> |
isChild(String parent) |
boolean |
isCompatable(Ontology other)
Determines if other is a compatible description (see
#describe(TypeNode) )
to this TypeHierarchy. |
void |
isCompatableThrow(Ontology other)
Determines if other is a compatible description (see
#describe(TypeNode) )
to this TypeHierarchy. |
Set<String> |
isDescendant(String parent) |
boolean |
isIndividual(String name)
Returns true if the agent "knows" about the token string in the parameter and it's an individual.
|
boolean |
isObject(String name)
Returns true if the agent "knows" about the token string in the parameter: it's either a type or an individual.
|
Set<String> |
isParent(String child)
Finals all parents (direct ancestors) of child.
|
boolean |
isPrivate() |
boolean |
isRelation(String name)
Returns true if the agent "knows" about the token string in the parameter and it's an relation.
|
boolean |
isType(String name)
Returns true if the agent "knows" about the token string in the parameter and it's a type.
|
static CASAOntology |
makeOntology(String name,
Ontology... superOntologies)
Constructs a new CASAOntology
|
static CASAOntology |
makeOntology2(String name,
String... superOntologies) |
static Status |
ontology_lispImpl(TransientAgent agent,
ParamsMap params,
AgentUI ui,
Environment env) |
private boolean |
primitiveRelation(String name) |
protected boolean |
queryMaplet(Relation relation,
Type domain,
Type range)
Determines if domainName and rangeName are related through relation relationName
WITHOUT TAKING INTO ACCOUNT the isa relationships of the domain and range.
|
boolean |
queryMaplet(String relationName,
String domainName,
String rangeName)
Determines if domainName and rangeName are related through relation relationName
WITHOUT TAKING INTO ACCOUNT the isa relationships of the domain and range.
|
protected boolean |
relatedTo(Relation relation,
String domain,
String range)
Determines if domain and range are related through relation relation.
|
protected Set<Type> |
relatedTo(Relation relation,
Type domain) |
protected boolean |
relatedTo(Relation relation,
Type domain,
Type range)
Determines if domain and range are related through relation relation.
|
Set<String> |
relatedTo(String relation,
String domain) |
boolean |
relatedTo(String relation,
String domain,
String range)
Determines if domain and range are related through relation relation.
|
private void |
setSymbol(String name)
Set TWO symbols for the parameter name: one for the unqualified name, and
another for the qualified name (ontology and name).
|
String |
toString()
Returns a string describing the ontolog in the following form (for example):
|
public static final String DEFAULT_FILE_EXTENSION
static CASAOntology primitiveOntology
static final String PRIMITIVE_ONTOLOGY
static ConcreteRelation isaParent
static ConcreteRelation isaAncestor
static ConcreteRelation isa
static ConcreteRelation isaChild
static ConcreteRelation isaDescendant
static ConcreteRelation isequal
static ConcreteRelation properInstanceOf
static ConcreteRelation instanceOf
public static final String ISAPARENT
public static final String ISAANCESTOR
public static final String ISA
public static final String ISACHILD
public static final String ISADESCENDANT
public static final String ISEQUAL
public static final String PROPERINSTANCEOF
public static final String INSTANCEOF
static Type top
public static final String TOP
static Type bottom
public static final String BOTTOM
private String name
private String filePath
static Map<String,CASAOntology> allOntologies
List<CASAOntology> superOntologies
HierarchicalDictionary<BaseType> tBox
HierarchicalDictionary
used to contain type objects in this ontology.HierarchicalDictionary<Relation> relations
HierarchicalDictionary
used to contain relation objects in this ontology.private CASAOntology(String name, CASAOntology... superOntologies) throws IllegalOperationException
allOntologies
unless it's name is null, empty, or begins with ".".name
- superOntologies
- IllegalOperationException
public String getName()
public boolean isPrivate()
public static CASAOntology getOntology(String name)
isPrivate()
).name
- the name of the ontology as specified in it's constructor and return by getName()
public static CASAOntology makeOntology(String name, Ontology... superOntologies) throws IllegalOperationException
name
- superOntologies
- IllegalOperationException
- If a CASAOntology with that name already exists.public static CASAOntology makeOntology2(String name, String... superOntologies) throws IllegalOperationException
IllegalOperationException
public void addSuperOntologies(Ontology... parentOntologies) throws IllegalOperationException
addSuperOntologies
in interface Ontology
IllegalOperationException
public void addSuperOntologies(String... superOntologyNames) throws IllegalOperationException
addSuperOntologies
in interface Ontology
IllegalOperationException
public ConcreteRelation declRelation(String name, ConcreteRelation basedOn, Relation.Property[] properties, ConstraintSimple domConstraint, ConstraintSimple ranConstraint, Object... otherParams) throws IllegalOperationException
#declRelation(String, ConcreteRelation, Property[], ConstraintSimple, ConstraintSimple, Object...)
after converting
the properties parameter.name
- basedOn
- properties
- otherParams
- any additional parametersIllegalOperationException
#declRelation(String, ConcreteRelation, Property[], ConstraintSimple, ConstraintSimple, Object...)
public void declRelation(String name, String basedOn, Set<Relation.Property> properties, Constraint domConstraint, Constraint ranConstraint, Object... otherParams) throws IllegalOperationException
declRelation
in interface Ontology
IllegalOperationException
public ConcreteRelation declRelation(String name, ConcreteRelation basedOn, Set<Relation.Property> properties, Constraint domConstraint, Constraint ranConstraint, Object... otherParams) throws IllegalOperationException
name
- The name of the new relation.basedOn
- The relation on which to base this relation; if null indicates that this relation is a either a primitive
relation itself (no properties case), or (if there are properties specified)
we should generate an auxilliary primitive relation (named uniquely based on the relation name).
on which to base this relation.properties
- the set of properties (INVERSE, SYMMETRIC, ASYMMETRIC, TRANSITIVE, REFLEXIVE, USES) for that the new relation should
exhibit.otherParams
- TODOIllegalOperationException
- if the relation name attempts to override a reserved relation or you are attempting
base a primitive (no properties) relation on another relation (basedOn!=null & properties.isEmpty).private boolean canBeBase(Set<Relation.Property> properties)
properties
- private boolean isAssignable(Set<Relation.Property> properties)
properties
- public BaseType declType(String name) throws IllegalOperationException
name
- IllegalOperationException
- if the name was illegal, or the type couldn't be added for some reason.public BaseType declIndividual(String name) throws IllegalOperationException
name
- IllegalOperationException
- if the name was illegal, or the type couldn't be added for some reason.private void setSymbol(String name) throws IllegalOperationException
name
- the symbol to be defined; this may be the qualified or unqualified name.IllegalOperationException
- if the name was illegal.public void declMaplet(String relationName, String domainName, String rangeName) throws IllegalOperationException
declMaplet
in interface Ontology
relationName
- domainName
- rangeName
- IllegalOperationException
- if the name was illegal, or the maplet couldn't be added for some reason.declMaplet(Relation, BaseType, BaseType)
public void declMaplet(Relation relation, String domainName, String rangeName) throws IllegalOperationException
relation
- domainName
- rangeName
- IllegalOperationException
- if the name was illegal, or the maplet couldn't be added for some reason.declMaplet(Relation, BaseType, BaseType)
protected void declMaplet(Relation relation, BaseType domain, BaseType range) throws IllegalOperationException
relationName
- domainName
- rangeName
- IllegalOperationException
- if the relation is non-assignable, or the maplet couldn't be added for some reason.public boolean queryMaplet(String relationName, String domainName, String rangeName) throws IllegalOperationException
relationName
- domainName
- rangeName
- IllegalOperationException
- if any of the parameters can't be found, etcqueryMaplet(Relation, Type, Type)
protected boolean queryMaplet(Relation relation, Type domain, Type range)
relation
- domain
- range
- IllegalOperationException
- if any of the parameters can't be found, etcpublic String toString()
(declOntology "events" ;loaded from file /Apple/CASA/dataFiles/events.ont.lisp ��'(isa) ;super ontologies (the search path is events, isa) ��'( ;ontology declarations ����(declType "event") ����(declType "event_AdvertisementAdded") ... (declMaplet event isa:TOP) (declMaplet event_advertisementEvent events:event) ... ��* ) )Note that some of the commented information might not be available.
toString
in interface Ontology
toString
in class Object
Object.toString()
private int appendMapletDecl(StringBuffer b, BaseType t, Relation rel)
public Relation getRelation(String name) throws IllegalOperationException
name
- IllegalOperationException
public BaseType getType(String name) throws IllegalOperationException
name
- IllegalOperationException
public void addType(String name, String... parents) throws ParentNodeNotFoundException, DuplicateNodeException, IllegalOperationException
declType(String)
for name
if it doesn't already exist.addType
in interface Ontology
name
- the name of new typeparents
- the super-types of name. Each member of parents
must already exist in the hierarchy.ParentNodeNotFoundException
- if any of the members of parents
isn't in the hierarchy.IllegalOperationException
DuplicateNodeException
Ontology.addType(java.lang.String, java.lang.String)
public void addType(String name, String parent) throws ParentNodeNotFoundException, DuplicateNodeException, IllegalOperationException
declType(String)
for name
if it doesn't already exist.addType
in interface Ontology
name
- the name of new typeparent
- the super-type of name.ParentNodeNotFoundException
- if parent
isn't in the hierarchy.IllegalOperationException
DuplicateNodeException
Ontology.addType(java.lang.String, java.lang.String)
public int add(String description) throws DuplicateNodeException, IncompatableTypeHierarchiesException, ParentNodeNotFoundException, ParseException
IncompatableTypeHierarchiesException
.
Instead execute the lisp commands (declOntology ...) or (with-ontology ...).add
in interface Ontology
IncompatableTypeHierarchiesException
ParentNodeNotFoundException
ParseException
DuplicateNodeException
Ontology.add(java.lang.String)
public String describe(String name) throws IllegalOperationException
describe
in interface Ontology
name
- the name of a node in the TypeHiearchyIllegalOperationException
- TODOOntology.describe(java.lang.String)
public String describe(BaseType type) throws IllegalOperationException
type
- IllegalOperationException
Ontology.describe(String)
private String describe2(Type theType, TreeSet<Type> doneTypes, TreeSet<String> doneRels) throws IllegalOperationException
IllegalOperationException
Ontology.describe(java.lang.String)
public String describeRelation(String relation) throws IllegalOperationException
describeRelation
in interface Ontology
IllegalOperationException
public String describeType(String type) throws IllegalOperationException
describeType
in interface Ontology
IllegalOperationException
public String describeIndividual(String type) throws IllegalOperationException
describeIndividual
in interface Ontology
IllegalOperationException
private String describeRel(Relation relation, TreeSet<String> doneRels)
Ontology.describe(java.lang.String)
private boolean primitiveRelation(String name)
name
- The name of a relationpublic boolean isCompatable(Ontology other)
Ontology
#describe(TypeNode)
)
to this TypeHierarchy.
Node A is compatible with node B iff all nodes in A that have matched names
in B are exactly the same as the corresponding node in B (that is, they have
the same name, and each of the parents [recursively] are exactly the same).
forall i:Node | i member B . exists j:Node | j member A . i.name = j.nameisCompatable
in interface Ontology
other
- the TypeHierarchy ot compare to this one for compatabilitypublic void isCompatableThrow(Ontology other) throws IncompatableTypeHierarchiesException
Ontology
#describe(TypeNode)
)
to this TypeHierarchy.
Node A is compatible with node B iff all nodes in A that have matched names
in B are exactly the same as the corresponding node in B (that is, they have
the same name, and each of the parents [recursively] are exactly the same).
forall i:Node | i member B . exists j:Node | j member A . i.name = j.nameisCompatableThrow
in interface Ontology
other
- the TypeHierarchy ot compare to this one for compatabilityIncompatableTypeHierarchiesException
- iff other is incompatablepublic boolean isObject(String name) throws IllegalOperationException
Ontology
isObject
in interface Ontology
name
- the name of the typeIllegalOperationException
- if the qualified syntax explicitly specifies a dictionary that is not the owner.Ontology.isObject(java.lang.String)
public boolean isType(String name) throws IllegalOperationException
Ontology
isType
in interface Ontology
name
- the name of a node in the TypeHiearchyIllegalOperationException
- if the qualified syntax explicitly specifies a dictionary that is not the owner.public boolean isIndividual(String name) throws IllegalOperationException
Ontology
isIndividual
in interface Ontology
name
- the name of a node in the TypeHiearchyIllegalOperationException
- if the qualified syntax explicitly specifies a dictionary that is not the owner.public boolean isa(String child, String parent) throws IllegalOperationException
isa
in interface Ontology
child
- the name if a node in the TypeHierarchyparent
- the name of a node in the TypeHierarchyIllegalOperationException
Ontology.isa(java.lang.String, java.lang.String)
,
relatedTo(Relation, Type, Type)
public boolean relatedTo(String relation, String domain, String range) throws UnsupportedOperationException, IllegalOperationException
queryMaplet(Relation, Type, Type)
and queryMaplet(String, String, String)
).relatedTo
in interface Ontology
relation
- domain
- rang
- IllegalOperationException
- if any of the parameters can't be found, etcUnsupportedOperationException
queryMaplet(Relation, Type, Type)
protected boolean relatedTo(Relation relation, String domain, String range) throws UnsupportedOperationException, IllegalOperationException
queryMaplet(Relation, Type, Type)
and queryMaplet(String, String, String)
).relation
- domain
- rang
- IllegalOperationException
- if any of the parameters can't be found, etcUnsupportedOperationException
#queryRelation(Relation, Type, Type)
protected boolean relatedTo(Relation relation, Type domain, Type range)
queryMaplet(Relation, Type, Type)
and queryMaplet(String, String, String)
).relation
- domain
- rang
- IllegalOperationException
- if any of the parameters can't be found, etcpublic Set<String> relatedTo(String relation, String domain) throws UnsupportedOperationException, IllegalOperationException
relatedTo
in interface Ontology
UnsupportedOperationException
IllegalOperationException
protected Set<Type> relatedTo(Relation relation, Type domain)
relation
- domain
- public Status extendWith(String spec)
extendWith
in interface Ontology
spec
- A String containing the persistent for of an
OntologyOntology.extendWith(java.lang.String)
public void addIndividual(String name, String parent) throws ParentNodeNotFoundException, DuplicateNodeException, IllegalOperationException
addIndividual
in interface Ontology
ParentNodeNotFoundException
DuplicateNodeException
IllegalOperationException
public static Status ontology_lispImpl(TransientAgent agent, ParamsMap params, AgentUI ui, Environment env) throws ControlTransfer
ControlTransfer
public static String[] getResident()
public void addIndividual(String name, String... parents) throws ParentNodeNotFoundException, DuplicateNodeException, IllegalOperationException
addIndividual
in interface Ontology
ParentNodeNotFoundException
DuplicateNodeException
IllegalOperationException
public boolean instanceOf(String child, String parent) throws IllegalOperationException
instanceOf
in interface Ontology
IllegalOperationException
public boolean isRelation(String name) throws IllegalOperationException
Ontology
isRelation
in interface Ontology
name
- the name of the relationIllegalOperationException
- if the qualified syntax explicitly specifies a dictionary that is not the owner.public Set<String> isa(String child) throws IllegalOperationException
Ontology
isa
in interface Ontology
child
- the name if a node in the TypeHierarchyIllegalOperationException
public Set<String> isParent(String child) throws IllegalOperationException
Ontology
isParent
in interface Ontology
child
- the name if a node in the TypeHierarchyIllegalOperationException
public Set<String> isAncestor(String child) throws IllegalOperationException
isAncestor
in interface Ontology
IllegalOperationException
public Set<String> isChild(String parent) throws IllegalOperationException
isChild
in interface Ontology
IllegalOperationException
public Set<String> isDescendant(String parent) throws IllegalOperationException
isDescendant
in interface Ontology
IllegalOperationException
public String getDefaultFileExtension()
getDefaultFileExtension
in interface Ontology