aminePlatform.kernel.ontology
Class Ontology

java.lang.Object
  extended byaminePlatform.kernel.ontology.Ontology
All Implemented Interfaces:
Graph, java.io.Serializable, SynergyTypeConstants
Direct Known Subclasses:
KnowledgeBase

public class Ontology
extends java.lang.Object
implements java.io.Serializable, Graph, SynergyTypeConstants

Title : ontology.Ontology Class

Description : An ontology in AminePlatform is a specialization/generalization graph of Conceptual Structures (CS).

A CS, which corresponds to graph's node, can represent a Concept Type, a Relation Type, an Individual or a Situation:

* Type CS/node (the class Type) : Each concept type and relation type is represented by this type of CS in the ontology. The definition and/or the canon of a type are stored in that node that represents the type in the ontology.

* RelationType CS/node (the class RelationType) : this a specialization of Type and it concerns Relation Type

* Individual CS/node (the class Individual) : An individual of a concept type is represented by an 'individual CS' that is immediately related to its type. The description of an individual is stored in this individual node.

* Situation CS/node (the class Situation) : A situation is stored in a situation node. A situation can be related to types, individuals and/or to other situations.

See classes CS, Type, RelationType, Individual and Situation for more details.

Hence, an ontology is a graph of Conceptual Structures (CS) with one main root (recorded by the ontology attribute 'rootType' which is a Type CS). A direct subtype of the type's main root is the relation root (recorded by the ontology attribute 'relationRoot' which is a RelationType CS).

Like nodes of a graph, each CS cs referes to the immediate CSs that cs specialize (the direct fathers of the CS cs) and to the immediate CSs that are specialization of the CS cs (the immediate children of the CS cs). Thus, the ontology is a specialization/generalization graph and the graph structure of the ontology is implicitly encoded by the links that are specified in each CS. See CS and the related classes for more details.

Also, each ontology is associated to it its lexicons. We make a clear distinction between the lexicons and the ontology : a lexicon contains the association between an identifier in a given language and a CS (which represents its 'meaning') while an ontology contains CSs and the relations between them, resulting in a (huge) graph of CSs. So lexicons and ontology have CSs in common.

To understand more deeply this independence between lexicons and ontology, please note that the description (content) of a CS, which could be a Conceptual Graph (CG) or any other knowledge representation formalism, is not composed of identifiers but of references to other CSs and so they are 'natural language free descriptions'.

Since CSs are 'natural language free descriptions', then the whole ontology is 'natural language free'. The use of identifiers and hence languages and lexicons occurs only when AminePlatform has to communicate or express its knowledge (descriptions) to another language-based system like human !

We can access the graph of CSs that constitute the body of the ontology from its main type root, from a CS/node or from an entry of a lexicon.

Note that the basic operations on an ontology, like addition of a new CS/node, relating CS/node to other CSs/nodes, type hierarchy operations (isSuperType, directSuperTypes, allSuperTypes, minimal common superType, etc.) are defined in the class CS and its subclasses (Type, Individual and Situation).

Finally, an important feature in our definition of lexicons, ontology and CSs is that they are independent and they are not committed to a particular description formalism or scheme. Indeed, content of CS can be any Java Object (see definition of classes CS, Type, Individual and Situation). Hence, different description formalisms (Conceptual Graph (CG), CycList, frame-like structure, RDF, KIF-like notation, etc.) could be used to describe the content of the CS, in so far that they are implemented in Java and allow for descriptions in terms of type, individuals and relations ! In our case, we are using CG and we provide several APIs to deal with them, but to iterate, our definition of lexicons, ontology and CS are not committed to CG only, other notations can be used instead of or beside CG (i.e., we can even define and use an ontology where different notations are used to describe CSs.

Copyright: Copyright (c) Adil KABBAJ, 2004-2009

See Also:
Serialized Form

Field Summary
static java.util.HashMap hmpKeyContexts
           
static boolean loadSynergyOntology
           
static boolean toXML
           
 
Fields inherited from interface aminePlatform.kernel.SynergyTypeConstants
ADD_IDENT, ADD_TYPE, AND_IDENT, AND_TYPE, ARITHMETIC_IDENT, ARITHMETIC_OPERS, ARITHMETIC_TYPE, ASSIGN_IDENT, ASSIGN_TYPE, BOOLEAN_IDENT, BOOLEAN_OPER_IDENT, BOOLEAN_OPER_TYPE, BOOLEAN_OPERS, BOOLEAN_TYPE, CG_IDENT, CG_TYPE, DATA_IDENT, DATA_TREATMENT, DATA_TYPE, DIF_IDENT, DIF_TYPE, DIV_IDENT, DIV_TYPE, DIVD_IDENT, EQUAL_IDENT, EQUAL_TYPE, FUNC_TYPE, FUNCTION_IDENT, GRD_IDENT, GRD_RELTYPE, GRD1_IDENT, GRD1_RELTYPE, GRTEQ_IDENT, GRTTHAN_IDENT, IN_IDENT, IN_OUT_IDENT, IN_OUT_OPERS, IN_OUT_TYPE, IN_RELTYPE, INF_IDENT, INF_TYPE, INFEQ_IDENT, INFEQ_TYPE, INT_IDENT, INT_TYPE, LAZY_IDENT, LAZY_TYPE, LESSEQ_IDENT, LESSTHAN_IDENT, LIST_IDENT, LIST_TYPE, MINUS_IDENT, MUL_IDENT, MUL_TYPE, MULT_IDENT, NEXT_IDENT, NEXT_RELTYPE, NOT_IDENT, NOT_TYPE, NOTEQ_IDENT, NOTEQ_TYPE, NOTEQL_IDENT, NUMBER_DATA, NUMBER_IDENT, NUMBER_TYPE, OBJECT_IDENT, OBJECT_TYPE, OPER_TYPE, OPERATION_IDENT, OR_IDENT, OR_TYPE, OUT_IDENT, OUT_RELTYPE, PLUS_IDENT, PRIMITIVE_FUNCTIONS, PROC_TYPE, PROCEDURE_IDENT, PROCESS_IDENT, PROCS_TYPE, READ_IDENT, READ_TYPE, REAL_IDENT, REAL_TYPE, RELATIONAL_IDENT, RELATIONAL_OPERS, RELATIONAL_TYPE, RELATIONS, SQRT_IDENT, SQRT_TYPE, STRING_IDENT, STRING_TYPE, SUB_IDENT, SUB_TYPE, SUP_IDENT, SUP_TYPE, SUPEQ_IDENT, SUPEQ_TYPE, SYN_REL_RELTYPE, SYN_TYP_RELTYPE, SYNERGY_DATA, SYNERGY_IDENTIFIERS, SYNERGY_OPERATIONS, SYNERGY_REL_IDENT, SYNERGY_TREATMENT, SYNERGY_TYPE_IDENT, TREATMENT_IDENT, TREATMENT_TYPE, TYPE_ARITHMETIC_OPERS, TYPE_BOOLEAN_OPERS, TYPE_IN_OUT_OPERS, TYPE_PRIMITIVE_FUNCTIONS, TYPE_RELATIONAL_OPERS, WRITE_IDENT, WRITE_TYPE
 
Constructor Summary
Ontology()
          Create an 'empty' Ontology.
Ontology(Identifier rootTypeIdentifier, Identifier relationRootIdentifier, Identifier mainLanguage)
          Create an ontology with the specified rootTypeIdentifier, rootRelationIdentifier and the mainLanguage.
Ontology(Identifier rootTypeIdentifier, Identifier relationRootIdentifier, Identifier mainLanguage, java.lang.Object[] languages)
          Create an ontology with the specified rootTypeIdentifier, rootRelationIdentifier, mainLanguage and languages.
Ontology(Type root)
          Create an Ontology with the specified root type.
Ontology(Type root, RelationType relationRoot)
          Create an ontology with the specified root as its root type CS and relationRoot as its relation root.
 
Method Summary
 void addEdge(Edge edge)
           
 boolean addLexicon(Lexicon lexicon)
          Add the specified lexicon to the list of lexicons associated to the current ontology.
 void addNode(Node node)
           
 void clear()
          Clear will destroy the content of the current ontology, including their lexicons, and it calls the garbage collector System.gc()
protected  void destroyOntologyGraph(Type root)
          Indepth traversal of the ontology graph to remove all its CSs.
 void finalize()
          destroy the whole ontology
 java.util.ArrayList getArrayLexicons()
           
 java.util.Enumeration getEdges()
           
protected  java.util.Enumeration getEdges(Type groot)
           
 java.util.Enumeration getLanguages()
          Get all the languages associated to the current ontology.
 java.lang.Object[] getLanguagesInArray()
          Get all the languages associated to the current ontology in an array.
 Lexicon getLexicon(Identifier language)
          Get the lexicon associated to the specified language.
 java.util.Enumeration getLexicons()
          Get all the lexicons that are associated to the current ontology
 Identifier getMainLanguage()
          Get the main language that is associated to the current ontology.
 Lexicon getMainLexicon()
          Get the main lexicon of the current ontology.
 boolean getMixedLanguage()
          Get the value of the mixedLanguage attribute which is common to all the lexicons associated to the current ontology.
 java.lang.String getName()
          Deprecated. This period is replaced by getPath()
 int getNbrLexicons()
          Get the number of lexicons associated to the current ontology
 java.util.Enumeration getNodes()
           
protected  java.lang.Object[] getNodesAndNbr(Type groot)
           
 java.lang.String getPath()
          Get the path of the current ontology.
 RelationType getRelationRoot()
          Get the relation root of the current ontology.
 Type getRoot()
          Get the root of the current ontology.
 int getSize()
           
static Identifier getSynergyRelIdent(java.lang.String sRelType)
           
static RelationType getSynergyRelType(java.lang.String sRelType)
           
 boolean hasIdentifiers(CS cs)
          This method checks if the specified cs has identifiers associated to it in some lexicons that are associated to the current ontology.
static org.jdom.Document importOntology(java.lang.String xmlDocumentPath)
          Return the XML ontology document existing in the specified path.
static boolean isASynergyIdent(Identifier ident)
           
 boolean isEmpty()
           
 boolean isKnownLanguage(Identifier language)
          Check if the specified language is among the languages associated to the lexicons of the current ontology.
 boolean isMainLanguage(Identifier language)
          Check if the given language corresponds to the main lexicon's language
 boolean isMainLexicon(Lexicon lexicon)
          Check if the given lexicon corresponds to the main lexicon of the current ontology
 boolean isMixedLanguage()
          Check if the mixedLanguage attribute is true.
 boolean isNewLanguage(Identifier language)
          The specified language is a new language if it is not among the languages associated to the lexicons of the current ontology.
 boolean isNewLanguageName(java.lang.String name)
          Check if the specified name is a new language name; no language has such a name among the languages associated to the lexicons of the current ontology.
static boolean isRoot(Type type)
          Check if the specified type corresponds to the root of the current ontology
static boolean isSynergyRelation(RelationType relType)
           
static boolean isSynergyRelation(java.lang.String sRelType)
           
static Ontology load(java.lang.String filePath)
          Load to the main memory, by deserialization, the ontology stored in filePath and return the ontology.
static Ontology loadOntologyFromXML(java.lang.String filePath, ParseCSDescription parseCSDescr)
          Load to the main memory, from an XML file, the ontology stored in filePath and return the ontology.
 void loadSynergyOntology()
           
 void makeEmpty()
           
 Node newNode(java.lang.String name, Lexicon lexicon)
          Implementation of Graph Interface
 Node newNode(java.lang.String name, Lexicon lexicon, java.lang.String choice)
           
static Ontology open(java.lang.String filePath)
          This method is equivalent to the method load(String filePath)
static Ontology openOntologyFromXML(java.lang.String filePath, ParseCSDescription parseCSDescr)
          This method is equivalent to the method loadFromXML(String filePath)
protected static void outputDocumentToFile(org.jdom.Document myDocument, Ontology ontology, java.lang.String filePath)
          Create the Xml document for the current ontology.
static Ontology parseOntologyFromXML(java.lang.String filePath, ParseCSDescription parseCSDescr)
          Parse the XML document in order to produce the internal representation of the ontology.
static void parseXMLSynonyms(Ontology ontology, Identifier identifier, org.jdom.Element elementtype)
           
protected  Type populate(org.jdom.Element ontologyelement, ParseCSDescription parseCSDescr)
           
 boolean removeCS(CS cs)
          Remove the specified CS cs from the current ontology.
 void removeEdge(Edge edge)
           
 boolean removeLexicon(Lexicon lexicon)
          Remove the specified lexicon from the list of lexicons associated to the current ontology.
 void removeNode(Node node)
           
 void save()
           
 void save(java.lang.String filePath)
          This method is equivalent to the method store(String filePath)
 void saveInXML(java.lang.String filePath)
          This method is equivalent to the method storeInXML(String filePath)
 void setLexicons(java.util.ArrayList lexicons)
           
 boolean setMainLexicon(Lexicon lexicon)
          Set the specified lexicon as the main lexicon for the current ontology if the main lexicon was not specified before.
 void setMixedLanguage(boolean b)
          Set a value for the attribute mixedLanguage.
 void setName(java.lang.String path)
          Deprecated. This period is replaced by setPath()
 void setPath(java.lang.String path)
          Set the specified path as the path of the current ontology
 boolean setRelationRoot(RelationType relationRoot)
          Set the specified type as the relation root of the current ontology if the ontology had no relation root before.
 boolean setRoot(Type rootType)
          Set the specified type as the root of the current ontology if the ontology had no root before.
 void store(java.lang.String filePath)
          Store, by serialization, the current ontology in the file filePath.
 void storeInXML(java.lang.String filePath)
          Store, in an XML file, the current ontology in the file filePath.
protected  void toXML(java.lang.String filePath)
           
protected  void toXMLWithIndepthTraversal(org.jdom.Element element, Type groot)
          Indepth traversal of the ontology graph to create an XML formulation of the Ontology.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

toXML

public static boolean toXML

loadSynergyOntology

public static boolean loadSynergyOntology

hmpKeyContexts

public static java.util.HashMap hmpKeyContexts
Constructor Detail

Ontology

public Ontology()
         throws OntologyException
Create an 'empty' Ontology. This is a minimal specification of an ontology. User could use setRoot(), setRelationRoot(), addLexicon() and other set up methods to complete this minimal creation of an ontology.

Throws:
OntologyException - if root is null.

Ontology

public Ontology(Type root)
         throws OntologyException
Create an Ontology with the specified root type. This is a minimal specification of an ontology. User could use setRelationRoot(), addLexicon() and other set up methods to complete this minimal creation of an ontology.

Parameters:
root - The main root type CS. root can not be null.
Throws:
OntologyException - if root is null.

Ontology

public Ontology(Type root,
                RelationType relationRoot)
         throws OntologyException
Create an ontology with the specified root as its root type CS and relationRoot as its relation root. If relationRoot is not null, the constructor will link relationRoot to root as a direct subType.

Parameters:
root - The main root type CS. root can not be null.
relationRoot - The relation root CS. relationRoot could be null.
Throws:
OntologyException - if root is null.

Ontology

public Ontology(Identifier rootTypeIdentifier,
                Identifier relationRootIdentifier,
                Identifier mainLanguage)
         throws OntologyException
Create an ontology with the specified rootTypeIdentifier, rootRelationIdentifier and the mainLanguage. The two identifiers are expressed in the main language. The lexicon for the main language will be created and associated to the current ontology. Types CS for rootTypeIdentifier and rootRelationIdentifier (if they are not null) are created and associated to their identifiers in the main lexicon. Also, if relationRootIdentifier is not null, its RelationType CS will be linked to the Type CS of relationRootIdentifier as a direct subType.

Parameters:
rootTypeIdentifier - The identifier of the root type. It can not be null.
mainLanguage - The identifier of the main language to associate with the current ontology. It can not be null.
Throws:
OntologyException - if rootTypeIdentifier or mainLanguage is null.

Ontology

public Ontology(Identifier rootTypeIdentifier,
                Identifier relationRootIdentifier,
                Identifier mainLanguage,
                java.lang.Object[] languages)
         throws java.lang.Exception
Create an ontology with the specified rootTypeIdentifier, rootRelationIdentifier, mainLanguage and languages. The two identifiers are expressed in the main language. The lexicon for the main language will be created and associated to the current ontology as well as the lexicon of each language of the parameter languages. Types CS for rootTypeIdentifier and rootRelationIdentifier (if they are not null) are created and associated to their identifiers in the main lexicon. Also, if relationRootIdentifier is not null, its Type CS will be linked to the Type CS of relationRootIdentifier as a direct subType.

Parameters:
rootTypeIdentifier - The identifier of the root type. It can not be null.
mainLanguage - The identifier of the main language to associate with the current ontology. It can not be null.
languages - The array of languages to associate with the current ontology. It could be null and it could contain (or not) the main language.
Throws:
OntologyException - if rootTypeIdentifier or mainLanguage is null, or throws LexiconException if languages contains duplication of languages.
java.lang.Exception
Method Detail

isASynergyIdent

public static boolean isASynergyIdent(Identifier ident)

loadSynergyOntology

public void loadSynergyOntology()

isSynergyRelation

public static boolean isSynergyRelation(RelationType relType)

isSynergyRelation

public static boolean isSynergyRelation(java.lang.String sRelType)

getSynergyRelType

public static RelationType getSynergyRelType(java.lang.String sRelType)

getSynergyRelIdent

public static Identifier getSynergyRelIdent(java.lang.String sRelType)

finalize

public void finalize()
destroy the whole ontology


clear

public void clear()
Clear will destroy the content of the current ontology, including their lexicons, and it calls the garbage collector System.gc()

Specified by:
clear in interface Graph

destroyOntologyGraph

protected void destroyOntologyGraph(Type root)
Indepth traversal of the ontology graph to remove all its CSs. Since the ontology is in general a huge graph, it is inefficient to do a recursive and simple indepth traversal. Instead, we use a stack in order to get all the CSs of the ontology, taking into account that a CS can have several direct fathers (since it is a graph and not only a tree) and the destruction of a CS should be done safely.


getLexicons

public java.util.Enumeration getLexicons()
Get all the lexicons that are associated to the current ontology

Returns:
an Enumeration over an ArrayList of Lexicon; all the lexicons that are associated to the current ontology

getArrayLexicons

public java.util.ArrayList getArrayLexicons()

setLexicons

public void setLexicons(java.util.ArrayList lexicons)

getNbrLexicons

public int getNbrLexicons()
Get the number of lexicons associated to the current ontology

Returns:
the number of lexicons associated to the current ontology

getLexicon

public Lexicon getLexicon(Identifier language)
Get the lexicon associated to the specified language.

Parameters:
language - An Identifier
Returns:
the lexicon associated to the specified language. Return null if language identifier is null or no lexicon for the specified language is associated to the current ontology.

addLexicon

public boolean addLexicon(Lexicon lexicon)
Add the specified lexicon to the list of lexicons associated to the current ontology.

Parameters:
lexicon - A Lexicon to associate to the current ontology
Returns:
true if lexicon was not contained in the list of lexicons associated to the current ontology

removeLexicon

public boolean removeLexicon(Lexicon lexicon)
Remove the specified lexicon from the list of lexicons associated to the current ontology. The lexicon itself is not destroyed however by this remove.

Parameters:
lexicon - A Lexicon to remove from the list of lexicons associated to the current ontology.
Returns:
true if the specified lexicon has been removed

getLanguages

public java.util.Enumeration getLanguages()
Get all the languages associated to the current ontology.

Returns:
an Enumeration over an ArrayList of Identifier; all the languages associated to the lexicons of the current ontology.

getLanguagesInArray

public java.lang.Object[] getLanguagesInArray()
Get all the languages associated to the current ontology in an array.

Returns:
an array of Identifier; all the languages associated to the lexicons of the current ontology.

getMainLanguage

public Identifier getMainLanguage()
Get the main language that is associated to the current ontology.

Returns:
the main language; the language associated to the main lexicon

isMainLanguage

public boolean isMainLanguage(Identifier language)
Check if the given language corresponds to the main lexicon's language

Parameters:
language - A language
Returns:
true if language is the main lexicon's language.

getMainLexicon

public Lexicon getMainLexicon()
Get the main lexicon of the current ontology.

Returns:
the main lexicon of the current ontology.

setMainLexicon

public boolean setMainLexicon(Lexicon lexicon)
Set the specified lexicon as the main lexicon for the current ontology if the main lexicon was not specified before. Note : once the main lexicon has been specified, it cannot be changed.

Parameters:
lexicon - A lexicon to consider as the main lexicon if this one was not specified before.
Returns:
true if the mainLexicon was not specified before this operation.

isMainLexicon

public boolean isMainLexicon(Lexicon lexicon)
Check if the given lexicon corresponds to the main lexicon of the current ontology

Parameters:
lexicon - A lexicon
Returns:
true if lexicon is the main lexicon of the current ontology.

getMixedLanguage

public boolean getMixedLanguage()
Get the value of the mixedLanguage attribute which is common to all the lexicons associated to the current ontology.

Returns:
true if mixedLanguage attribute is true.

isMixedLanguage

public boolean isMixedLanguage()
Check if the mixedLanguage attribute is true.

Returns:
true if mixedLanguage is true

setMixedLanguage

public void setMixedLanguage(boolean b)
Set a value for the attribute mixedLanguage. To enable mixed language descriptions, set the attribute to true (with this method), and set it to false to desable such a possibility. At any moment, the mixedLanguage attribute can be turned on/off and so enable/desable the possibility of mixed language descriptions for the current ontology.

Parameters:
b - true to enable mixed language descriptions and false to desable the possibility of mixed language descriptions.

isKnownLanguage

public boolean isKnownLanguage(Identifier language)
Check if the specified language is among the languages associated to the lexicons of the current ontology.

Parameters:
language - An Identifier that represents a language
Returns:
true if language is among the languages associated to the lexicons of the current ontology.

isNewLanguage

public boolean isNewLanguage(Identifier language)
The specified language is a new language if it is not among the languages associated to the lexicons of the current ontology. This method is basically the negation of the method isKnownLanguage(language).

Parameters:
language - A language
Returns:
true if language is not among the languages.

isNewLanguageName

public boolean isNewLanguageName(java.lang.String name)
Check if the specified name is a new language name; no language has such a name among the languages associated to the lexicons of the current ontology.

Parameters:
name - A String
Returns:
true if name is not a name of any language associated to the lexicons of the current ontology.

getRoot

public Type getRoot()
Get the root of the current ontology.

Returns:
the root type CS of the current ontology

isRoot

public static boolean isRoot(Type type)
Check if the specified type corresponds to the root of the current ontology

Parameters:
type -
Returns:

getRelationRoot

public RelationType getRelationRoot()
Get the relation root of the current ontology.

Returns:
the relation root type CS of the current ontology

setRelationRoot

public boolean setRelationRoot(RelationType relationRoot)
Set the specified type as the relation root of the current ontology if the ontology had no relation root before.

Parameters:
relationRoot - A Type CS to consider as the relation root of the current ontology
Returns:
true if the current ontology had no relation root before

setRoot

public boolean setRoot(Type rootType)
Set the specified type as the root of the current ontology if the ontology had no root before.

Parameters:
rootType - A Type CS to consider as the root of the current ontology
Returns:
true if the current ontology had no root before

getPath

public java.lang.String getPath()
Get the path of the current ontology.

Returns:
the file path of the ontology

setPath

public void setPath(java.lang.String path)
Set the specified path as the path of the current ontology

Parameters:
path - The (file) path of the current ontology

getName

public java.lang.String getName()
Deprecated. This period is replaced by getPath()

Get the path of the current ontology.

Returns:
the file path of the ontology

setName

public void setName(java.lang.String path)
Deprecated. This period is replaced by setPath()

Set the specified path as the path of the current ontology

Parameters:
path - The (file) path of the current ontology

open

public static Ontology open(java.lang.String filePath)
                     throws java.lang.Exception
This method is equivalent to the method load(String filePath)

Parameters:
filePath - is the file path for the file that contain an internal representation of the ontology
Returns:
the Ontology in term of a Java Object that corresponds to a (huge) graph.
Throws:
Exceptions - can occur during the deserialization process
java.lang.Exception

load

public static Ontology load(java.lang.String filePath)
                     throws java.lang.Exception
Load to the main memory, by deserialization, the ontology stored in filePath and return the ontology. The file stores the result of the serialization of an ontology. The filePath is then assigned to the attribute 'ontologyName' of the ontology.

Parameters:
filePath - is the file path for the file that contain an internal representation of the ontology
Returns:
the Ontology in term of a Java Object that corresponds to a (huge) graph.
Throws:
Exceptions - can occur during the deserialization process
java.lang.Exception

save

public void save(java.lang.String filePath)
          throws java.lang.Exception
This method is equivalent to the method store(String filePath)

Parameters:
filePath - is the file path for the file where the internal representation of the ontology will be saved
Throws:
java.lang.Exception

store

public void store(java.lang.String filePath)
           throws java.lang.Exception
Store, by serialization, the current ontology in the file filePath.

Parameters:
filePath - is the file path for the file where the internal representation of the ontology will be stored
Throws:
java.lang.Exception

save

public void save()
          throws java.lang.Exception
Throws:
java.lang.Exception

saveInXML

public void saveInXML(java.lang.String filePath)
               throws java.lang.Exception
This method is equivalent to the method storeInXML(String filePath)

Parameters:
filePath - is the file path for the file where the XML representation of the ontology will be saved
Throws:
java.lang.Exception

storeInXML

public void storeInXML(java.lang.String filePath)
                throws java.lang.Exception
Store, in an XML file, the current ontology in the file filePath.

Parameters:
filePath - is the file path for the file where the XML representation of the ontology will be stored
Throws:
java.lang.Exception

hasIdentifiers

public boolean hasIdentifiers(CS cs)
This method checks if the specified cs has identifiers associated to it in some lexicons that are associated to the current ontology.

Parameters:
cs - A CS
Returns:
true if cs has identifiers associated to it in some lexicons that are associated to the current ontology.

removeCS

public boolean removeCS(CS cs)
Remove the specified CS cs from the current ontology. The method checks first that the given cs is not the main root or the relation root and that cs can be removed (cs should not have children). Remove cs corresponds first to remove all links that relate cs as a child to its fathers. The cs is thus detached from all the other CSs that were connected to it but cs itself is not destroyed. Second, the method will remove all the entries in all the lexicons associated to the current ontology for all the identifiers associated to the specified cs. Note : Other forms of node's remove could be adopted : remove the cs and its descendants, remove the cs and attach its children to its fathers, etc. These forms can be added to Amine Platform when needed.

Parameters:
cs - is the cs to remove from the current ontology
Returns:
true if cs is not null and it can be removed and cs is neither the main root type nor the relation root type.

newNode

public Node newNode(java.lang.String name,
                    Lexicon lexicon,
                    java.lang.String choice)
             throws java.lang.Exception
Throws:
java.lang.Exception

loadOntologyFromXML

public static Ontology loadOntologyFromXML(java.lang.String filePath,
                                           ParseCSDescription parseCSDescr)
                                    throws java.lang.Exception
Load to the main memory, from an XML file, the ontology stored in filePath and return the ontology. The filePath is then assigned to the attribute 'ontologyName' of the ontology.

Parameters:
filePath - is the file path for the file that contain an XML representation of the ontology
Returns:
the Ontology in term of a Java Object that corresponds to a (huge) graph.
Throws:
Exceptions - can occur during the parsing process
java.lang.Exception

openOntologyFromXML

public static Ontology openOntologyFromXML(java.lang.String filePath,
                                           ParseCSDescription parseCSDescr)
                                    throws java.lang.Exception
This method is equivalent to the method loadFromXML(String filePath)

Parameters:
filePath - is the file path for the file that contain an XML representation of the ontology
Returns:
the Ontology in term of a Java Object that corresponds to a (huge) graph.
Throws:
Exceptions - can occur during the parsing process
java.lang.Exception

parseOntologyFromXML

public static Ontology parseOntologyFromXML(java.lang.String filePath,
                                            ParseCSDescription parseCSDescr)
Parse the XML document in order to produce the internal representation of the ontology.

Returns:
the internal representation of the ontology

populate

protected Type populate(org.jdom.Element ontologyelement,
                        ParseCSDescription parseCSDescr)

parseXMLSynonyms

public static void parseXMLSynonyms(Ontology ontology,
                                    Identifier identifier,
                                    org.jdom.Element elementtype)

importOntology

public static org.jdom.Document importOntology(java.lang.String xmlDocumentPath)
Return the XML ontology document existing in the specified path.

Parameters:
xmlDocumentPath - is the path of XML document where the ontology is saved in the XML format.
Returns:
ontologydoc

newNode

public Node newNode(java.lang.String name,
                    Lexicon lexicon)
             throws java.lang.Exception
Implementation of Graph Interface

Specified by:
newNode in interface Graph
Throws:
java.lang.Exception

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Graph

getNodes

public java.util.Enumeration getNodes()
Specified by:
getNodes in interface Graph

getNodesAndNbr

protected java.lang.Object[] getNodesAndNbr(Type groot)

getEdges

public java.util.Enumeration getEdges()
Specified by:
getEdges in interface Graph

getEdges

protected java.util.Enumeration getEdges(Type groot)

addEdge

public void addEdge(Edge edge)
Specified by:
addEdge in interface Graph

addNode

public void addNode(Node node)
Specified by:
addNode in interface Graph

removeNode

public void removeNode(Node node)
Specified by:
removeNode in interface Graph

removeEdge

public void removeEdge(Edge edge)
Specified by:
removeEdge in interface Graph

getSize

public int getSize()
Specified by:
getSize in interface Graph

makeEmpty

public void makeEmpty()
Specified by:
makeEmpty in interface Graph

toXMLWithIndepthTraversal

protected void toXMLWithIndepthTraversal(org.jdom.Element element,
                                         Type groot)
Indepth traversal of the ontology graph to create an XML formulation of the Ontology. Since the ontology is in general a huge graph, it is inefficient to do a recursive and simple indepth traversal. Instead, we use a stack in order to get all the CSs of the ontology, taking into account that a CS can have several direct fathers (since it is a graph and not only a tree) and so it can be visited several times. We use a HashMap to store visited nodes/CSs, with : if CS is a (Relation)Type or an Individual, than Value will be the identifier name returned by CS.getIdentifier(). If CS is a situation, than we associate its toString() since a situation has not an identifier in a lexicon.


toXML

protected void toXML(java.lang.String filePath)

outputDocumentToFile

protected static void outputDocumentToFile(org.jdom.Document myDocument,
                                           Ontology ontology,
                                           java.lang.String filePath)
Create the Xml document for the current ontology.

Parameters:
myDocument -
ontology -