Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Beginner EODM question
Beginner EODM question [message #27785] Thu, 09 March 2006 02:58 Go to next message
Eclipse UserFriend
Originally posted by: glenn.everitt.gmail.com

I think what I want to do is:

1. load an existing owl ontology
2. create a series of statements add them to the model
3. execute a couple of queries against the model (SPARQL queries?)

I downloaded the IODT toolkit from IBM alphaworks and I think the
LoadAndSaveOwlbyOWLFile shows me how to load and parse and owl document into
an owl ontology. (Please correct me if I am using terms incorrectly.)

OWLParser parser = new OWLParserImpl();

//New an OWL Document
OWLDocument food = new OWLDocumentImpl("./testcase/food.owl", null,
true);

//Add the document into the parser
parser.addOWLDocument(food);

//Start to parse OWL documents and get OWL ontologies
OWLOntology ontofood = parser.parseOWLDocument(food);

Now I want to add a statement

//create some RDF statement
RDFSFactory rdfsFactory = RDFSFactory.eINSTANCE;

RDFSResource subjectResource =
rdfsFactory.createRDFSResource(ontofood , subjectURI);

RDFProperty subjectProperty = rdfsFactory.createRDFProperty(ontofood
, predicateURI);

RDFSLiteral literal = rdfsFactory.createRDFSLiteral(ontofood ,
objectStringLiteral);

RDFStatement statement = rdfsFactory.createRDFStatement(ontofood ,
subjectResource, subjectProperty, literal);

Now is statement already in the ontofood ontology?

How would I go about writing a query to find the all subjectResource items
with the same subjectProperty?

Thanks for any help - Glenn
Re: Beginner EODM question [message #28070 is a reply to message #27785] Fri, 10 March 2006 07:26 Go to previous messageGo to next message
Yang Yang is currently offline Yang YangFriend
Messages: 10
Registered: July 2009
Junior Member
This is a multipart message in MIME format.
--=_alternative 0028C6D84825712D_=
Content-Type: text/plain; charset="US-ASCII"

Hello Glenn,

**) In OWL model of EODM, the RDFStatement is used to those reified
statements. For example, If you create a statement s1 by the following
codes:

//create some RDF statement
RDFSFactory rdfsFactory = RDFSFactory.eINSTANCE;

// if you want to use the exiting resource from the Ontology that
you load,
// you can use Ontology.getContainedResource(Namespace namespace,
String localName) to get its java object
RDFSResource subjectResource =
rdfsFactory.createRDFSResource(ontofood , subjectURI);
RDFProperty subjectProperty =
rdfsFactory.createRDFProperty(ontofood, predicateURI);
RDFSLiteral literal = rdfsFactory.createRDFSLiteral(ontofood ,
objectStringLiteral);

RDFStatement statement = rdfsFactory.createRDFStatement(ontofood ,
subjectResource, subjectProperty, literal);
statement.setLocalName("s1"); // assign a local name to this
statement

As a result, Statement s1 will be in ontology. But it will be a REIFIED
STATEMENT which only means "s1 is a statement whose subject is subjectURI
... ". It will not create a triple <subjectURI predicateURI
objectStringLiteral> in the model.


The way to declare triples in OWL model of EODM is through the interface
boolean Individual.addPropertyValue(RDFProperty property,
RDFSResource resource);
For example, to declare "john like basketball" in the model, you can use
the following codes:

OWLClass Person = factory.createOWLClass(ontology,"Person");
OWLClass Sports = factory.createOWLClass(ontology,"Sports");
OWLObjectProperty like =
factory.createOWLObjectProperty(ontology,"like");

Individual baseball =
factory.createIndividual(ontology,"BaseBall",Sports);
Individual john =
factory.createIndividual(ontology,"john",Person);
john.addPropertyValue(like,baseball);



**) Currently the main target of EODM is to manipulate ontology model in
conceptual level, even though there are interfaces in EODM to declare
instances and triples. Therefore, there is no query engine for EODM to
query instances. However, you can use another component of IODT - minerva
to deal with queries for instances. Please see more detail in the miverva
documents. The following are the example codes:


// set up config file for minerva
Config.setConfigFile(new
FileInputStream("config/minerva-HSQL.cfg"));
Config.install();

//generate an ontology store manager
OntologyStoreManager minerva = new OntologyStoreManager();

minerva.deleteOntologyStore("test"); //delete an ontology store
if it has already there
minerva.newOntologyStore("test");

// load EODM model into minerva
minerva.addEODMModel(ontology,false);

//do inference
minerva.commit();

// start sparql query
String q1 = "PREFIX test:<http://test.org/test#> SELECT * WHERE
(?x test:like test:Baseball)";

try {
//issue a query and get results

ResultHolder result = minerva.getQueryResult(q1);
//get variable name
String[] name=result.getVariablename();
for (int i =0; i<name.length;i++)
System.out.print(name[i]+" ");
System.out.println();
//traverse result set
while (result.next()){
for (int i =0; i<name.length;i++)
System.out.print(result.getInt(i+1)+" ");
System.out.println();
}

result.close() ;

}catch(RecognitionException e)
{
System.err.println("Encounting parse error");
e.printStackTrace();
}
catch (TokenStreamException e) {
System.err.println("Encounting parse error");
e.printStackTrace();
}
catch(SQLException e)
{
System.err.println("Encounting database error");
e.printStackTrace();
}

The contents of minerva-HSQL.cfg:

Database = jdbc:hsqldb:file:minervademo
User = sa
Password =
Driver = org.hsqldb.jdbcDriver
TboxEngine = Default
DuplicateRemover = false










--=_alternative 0028C6D84825712D_=
Content-Type: text/html; charset="US-ASCII"


<br><font size=2 face="sans-serif">Hello </font><font size=2><tt>Glenn</tt></font><font size=2 face="sans-serif">,</font>
<br>
<br><font size=2 face="sans-serif">**) In OWL model of EODM, the RDFStatement
is used to those reified statements. For example, If you create a statement
s1 by the following codes:</font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; &nbsp; </tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; &nbsp; //create some RDF statement<br>
&nbsp; &nbsp; &nbsp; &nbsp;RDFSFactory rdfsFactory = RDFSFactory.eINSTANCE;<br>
</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; &nbsp; // if you want to use
the exiting resource from the Ontology that you load,</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; &nbsp; // you can use Ontology.getContainedResource(Namespace
namespace, String localName) to get its java object<br>
&nbsp; &nbsp; &nbsp; &nbsp;RDFSResource subjectResource = rdfsFactory.createRDFSResource(ontofood
, subjectURI);<br>
&nbsp; &nbsp; &nbsp; &nbsp;RDFProperty subjectProperty = rdfsFactory.createRDFProperty(ontofood,
predicateURI);<br>
&nbsp; &nbsp; &nbsp; &nbsp;RDFSLiteral literal = rdfsFactory.createRDFSLiteral(ontofood
, objectStringLiteral);<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;RDFStatement statement = rdfsFactory.createRDFStatement(ontofood
, subjectResource, subjectProperty, literal);</tt></font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
statement.setLocalName(&quot;s1&quot;); // assign a local name to this
statement</font>
<br><font size=2 face="sans-serif">&nbsp; </font>
<br><font size=2 face="sans-serif">As a result, Statement s1 will be in
ontology. But it will be a REIFIED STATEMENT which only means &quot;s1
is a statement whose subject is </font><font size=2><tt>subjectURI</tt></font><font size=2 face="sans-serif">...
&quot;. It will not create a triple &lt;</font><font size=2><tt>subjectURI</tt></font><font size=2 face="sans-serif">
</font><font size=2><tt>predicateURI</tt></font><font size=2 face="sans-serif">
</font><font size=2><tt>objectStringLiteral</tt></font><font size=2 face="sans-serif">&gt;
in the model.</font>
<br>
<br>
<br><font size=2 face="sans-serif">The way to declare triples in OWL model
of EODM is through the interface </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;boolean Individual.addPropertyValue(RDFProperty
property, RDFSResource resource);</font>
<br><font size=2 face="sans-serif">For example, to declare &quot;john like
basketball&quot; in the model, you can use the following codes:</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
OWLClass Person = factory.createOWLClass(ontology,&quot;Person&quot;); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
OWLClass Sports = factory.createOWLClass(ontology,&quot;Sports&quot;); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
OWLObjectProperty like = factory.createOWLObjectProperty(ontology,&quot;like& quot;); </font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Individual
baseball = factory.createIndividual(ontology,&quot;BaseBall&quo t;,Sports); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Individual
john = factory.createIndividual(ontology,&quot;john&quot;,P erson); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
john.addPropertyValue(like,baseball);</font>
<br>
<br>
<br>
<br><font size=2 face="sans-serif">**) Currently the main target of EODM
is to manipulate ontology model in conceptual level, even though there
are interfaces in EODM to declare instances and triples. Therefore, there
is no query engine for EODM to query instances. However, you can use another
component of IODT - minerva to deal with queries for instances. Please
see more detail in the miverva documents. The following are the example
codes:</font>
<br>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // set up
config file for minerva</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Config.setConfigFile(new
FileInputStream(&quot;config/minerva-HSQL.cfg&quot;) ); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Config.install();</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; //generate
an ontology store manager</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; OntologyStoreManager
minerva = new OntologyStoreManager();</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; minerva.deleteOntologyStore(&quot;test&quot;);
&nbsp;//delete an ontology store if it has already there</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; minerva.newOntologyStore(&quot;test&quot;);</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
// load EODM model into minerva</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; minerva.addEODMModel(ontology,false);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; //do inference</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; minerva.commit();</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
// start sparql query</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; String q1
= &quot;PREFIX test:&lt;http://test.org/test#&gt; SELECT * WHERE (?x test:like
test:Baseball)&quot;;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; try {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
//issue a query and get results</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
ResultHolder result = minerva.getQueryResult(q1);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
//get variable name</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
String[] name=result.getVariablename();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
for (int i =0; i&lt;name.length;i++)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; System.out.print(name[i]+&quot; &nbsp; &nbsp;&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
System.out.println();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
//traverse result set</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
while (result.next()){</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; for (int i =0; i&lt;name.length;i++)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; System.out.print(result.getInt(i+1)+&quot;
&nbsp; &quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; System.out.println();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
}</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
result.close() ; &nbsp; &nbsp;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }catch(RecognitionException
e)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
System.err.println(&quot;Encounting parse error&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
e.printStackTrace();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; catch (TokenStreamException
e) {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
System.err.println(&quot;Encounting parse error&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
e.printStackTrace();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; catch(SQLException
e)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
System.err.println(&quot;Encounting database error&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
e.printStackTrace();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br><font size=2 face="sans-serif">The contents of minerva-HSQL.cfg:</font>
<br>
<br><font size=2 face="Courier New">Database = jdbc:hsqldb:file:minervademo</font>
<br><font size=2 face="Courier New">User = sa</font>
<br><font size=2 face="Courier New">Password = </font>
<br><font size=2 face="Courier New">Driver = org.hsqldb.jdbcDriver</font>
<br><font size=2 face="Courier New">TboxEngine = Default</font>
<br><font size=2 face="Courier New">DuplicateRemover = false</font>
<br>
<br>
<br>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br>
<br>
<br>
<br>
<br>
--=_alternative 0028C6D84825712D_=--
Re: Beginner EODM question [message #28109 is a reply to message #28070] Fri, 10 March 2006 07:55 Go to previous message
Eclipse UserFriend
Originally posted by: gordon.xx.com

The website of EODM at Eclipse.org is still under construction. Currently,
the only source to get documentation of EODM, and IODT (IBM Integrated
Ontology Development Toolkit), the toolkit that contains EODM, is
alphaWorks. You can find:
- sample code to manipulate EODM to creat ontologies, with instances
- sample code to store EODM into Minerva and use SPARQL to query

I'm not sure what version of IODT you are using. We are updating
alphaWorks with IODT v1.1.1, so please make sure that you are using the
latest version.
Re: Beginner EODM question [message #571852 is a reply to message #27785] Fri, 10 March 2006 07:26 Go to previous message
Yang Yang is currently offline Yang YangFriend
Messages: 10
Registered: July 2009
Junior Member
This is a multipart message in MIME format.
--=_alternative 0028C6D84825712D_=
Content-Type: text/plain; charset="US-ASCII"

Hello Glenn,

**) In OWL model of EODM, the RDFStatement is used to those reified
statements. For example, If you create a statement s1 by the following
codes:

//create some RDF statement
RDFSFactory rdfsFactory = RDFSFactory.eINSTANCE;

// if you want to use the exiting resource from the Ontology that
you load,
// you can use Ontology.getContainedResource(Namespace namespace,
String localName) to get its java object
RDFSResource subjectResource =
rdfsFactory.createRDFSResource(ontofood , subjectURI);
RDFProperty subjectProperty =
rdfsFactory.createRDFProperty(ontofood, predicateURI);
RDFSLiteral literal = rdfsFactory.createRDFSLiteral(ontofood ,
objectStringLiteral);

RDFStatement statement = rdfsFactory.createRDFStatement(ontofood ,
subjectResource, subjectProperty, literal);
statement.setLocalName("s1"); // assign a local name to this
statement

As a result, Statement s1 will be in ontology. But it will be a REIFIED
STATEMENT which only means "s1 is a statement whose subject is subjectURI
... ". It will not create a triple <subjectURI predicateURI
objectStringLiteral> in the model.


The way to declare triples in OWL model of EODM is through the interface
boolean Individual.addPropertyValue(RDFProperty property,
RDFSResource resource);
For example, to declare "john like basketball" in the model, you can use
the following codes:

OWLClass Person = factory.createOWLClass(ontology,"Person");
OWLClass Sports = factory.createOWLClass(ontology,"Sports");
OWLObjectProperty like =
factory.createOWLObjectProperty(ontology,"like");

Individual baseball =
factory.createIndividual(ontology,"BaseBall",Sports);
Individual john =
factory.createIndividual(ontology,"john",Person);
john.addPropertyValue(like,baseball);



**) Currently the main target of EODM is to manipulate ontology model in
conceptual level, even though there are interfaces in EODM to declare
instances and triples. Therefore, there is no query engine for EODM to
query instances. However, you can use another component of IODT - minerva
to deal with queries for instances. Please see more detail in the miverva
documents. The following are the example codes:


// set up config file for minerva
Config.setConfigFile(new
FileInputStream("config/minerva-HSQL.cfg"));
Config.install();

//generate an ontology store manager
OntologyStoreManager minerva = new OntologyStoreManager();

minerva.deleteOntologyStore("test"); //delete an ontology store
if it has already there
minerva.newOntologyStore("test");

// load EODM model into minerva
minerva.addEODMModel(ontology,false);

//do inference
minerva.commit();

// start sparql query
String q1 = "PREFIX test:<http://test.org/test#> SELECT * WHERE
(?x test:like test:Baseball)";

try {
//issue a query and get results

ResultHolder result = minerva.getQueryResult(q1);
//get variable name
String[] name=result.getVariablename();
for (int i =0; i<name.length;i++)
System.out.print(name[i]+" ");
System.out.println();
//traverse result set
while (result.next()){
for (int i =0; i<name.length;i++)
System.out.print(result.getInt(i+1)+" ");
System.out.println();
}

result.close() ;

}catch(RecognitionException e)
{
System.err.println("Encounting parse error");
e.printStackTrace();
}
catch (TokenStreamException e) {
System.err.println("Encounting parse error");
e.printStackTrace();
}
catch(SQLException e)
{
System.err.println("Encounting database error");
e.printStackTrace();
}

The contents of minerva-HSQL.cfg:

Database = jdbc:hsqldb:file:minervademo
User = sa
Password =
Driver = org.hsqldb.jdbcDriver
TboxEngine = Default
DuplicateRemover = false










--=_alternative 0028C6D84825712D_=
Content-Type: text/html; charset="US-ASCII"


<br><font size=2 face="sans-serif">Hello </font><font size=2><tt>Glenn</tt></font><font size=2 face="sans-serif">,</font>
<br>
<br><font size=2 face="sans-serif">**) In OWL model of EODM, the RDFStatement
is used to those reified statements. For example, If you create a statement
s1 by the following codes:</font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; &nbsp; </tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; &nbsp; //create some RDF statement<br>
&nbsp; &nbsp; &nbsp; &nbsp;RDFSFactory rdfsFactory = RDFSFactory.eINSTANCE;<br>
</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; &nbsp; // if you want to use
the exiting resource from the Ontology that you load,</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; &nbsp; // you can use Ontology.getContainedResource(Namespace
namespace, String localName) to get its java object<br>
&nbsp; &nbsp; &nbsp; &nbsp;RDFSResource subjectResource = rdfsFactory.createRDFSResource(ontofood
, subjectURI);<br>
&nbsp; &nbsp; &nbsp; &nbsp;RDFProperty subjectProperty = rdfsFactory.createRDFProperty(ontofood,
predicateURI);<br>
&nbsp; &nbsp; &nbsp; &nbsp;RDFSLiteral literal = rdfsFactory.createRDFSLiteral(ontofood
, objectStringLiteral);<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;RDFStatement statement = rdfsFactory.createRDFStatement(ontofood
, subjectResource, subjectProperty, literal);</tt></font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
statement.setLocalName(&quot;s1&quot;); // assign a local name to this
statement</font>
<br><font size=2 face="sans-serif">&nbsp; </font>
<br><font size=2 face="sans-serif">As a result, Statement s1 will be in
ontology. But it will be a REIFIED STATEMENT which only means &quot;s1
is a statement whose subject is </font><font size=2><tt>subjectURI</tt></font><font size=2 face="sans-serif">...
&quot;. It will not create a triple &lt;</font><font size=2><tt>subjectURI</tt></font><font size=2 face="sans-serif">
</font><font size=2><tt>predicateURI</tt></font><font size=2 face="sans-serif">
</font><font size=2><tt>objectStringLiteral</tt></font><font size=2 face="sans-serif">&gt;
in the model.</font>
<br>
<br>
<br><font size=2 face="sans-serif">The way to declare triples in OWL model
of EODM is through the interface </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;boolean Individual.addPropertyValue(RDFProperty
property, RDFSResource resource);</font>
<br><font size=2 face="sans-serif">For example, to declare &quot;john like
basketball&quot; in the model, you can use the following codes:</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
OWLClass Person = factory.createOWLClass(ontology,&quot;Person&quot;); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
OWLClass Sports = factory.createOWLClass(ontology,&quot;Sports&quot;); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
OWLObjectProperty like = factory.createOWLObjectProperty(ontology,&quot;like& quot;); </font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Individual
baseball = factory.createIndividual(ontology,&quot;BaseBall&quo t;,Sports); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Individual
john = factory.createIndividual(ontology,&quot;john&quot;,P erson); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
john.addPropertyValue(like,baseball);</font>
<br>
<br>
<br>
<br><font size=2 face="sans-serif">**) Currently the main target of EODM
is to manipulate ontology model in conceptual level, even though there
are interfaces in EODM to declare instances and triples. Therefore, there
is no query engine for EODM to query instances. However, you can use another
component of IODT - minerva to deal with queries for instances. Please
see more detail in the miverva documents. The following are the example
codes:</font>
<br>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; // set up
config file for minerva</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Config.setConfigFile(new
FileInputStream(&quot;config/minerva-HSQL.cfg&quot;) ); </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Config.install();</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; //generate
an ontology store manager</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; OntologyStoreManager
minerva = new OntologyStoreManager();</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; minerva.deleteOntologyStore(&quot;test&quot;);
&nbsp;//delete an ontology store if it has already there</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; minerva.newOntologyStore(&quot;test&quot;);</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
// load EODM model into minerva</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; minerva.addEODMModel(ontology,false);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; //do inference</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; minerva.commit();</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
// start sparql query</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; String q1
= &quot;PREFIX test:&lt;http://test.org/test#&gt; SELECT * WHERE (?x test:like
test:Baseball)&quot;;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; try {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
//issue a query and get results</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
ResultHolder result = minerva.getQueryResult(q1);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
//get variable name</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
String[] name=result.getVariablename();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
for (int i =0; i&lt;name.length;i++)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; System.out.print(name[i]+&quot; &nbsp; &nbsp;&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
System.out.println();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
//traverse result set</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
while (result.next()){</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; for (int i =0; i&lt;name.length;i++)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; System.out.print(result.getInt(i+1)+&quot;
&nbsp; &quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; System.out.println();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
}</font>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
result.close() ; &nbsp; &nbsp;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }catch(RecognitionException
e)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
System.err.println(&quot;Encounting parse error&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
e.printStackTrace();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; catch (TokenStreamException
e) {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
System.err.println(&quot;Encounting parse error&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
e.printStackTrace();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; catch(SQLException
e)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
System.err.println(&quot;Encounting database error&quot;);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
e.printStackTrace();</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br><font size=2 face="sans-serif">The contents of minerva-HSQL.cfg:</font>
<br>
<br><font size=2 face="Courier New">Database = jdbc:hsqldb:file:minervademo</font>
<br><font size=2 face="Courier New">User = sa</font>
<br><font size=2 face="Courier New">Password = </font>
<br><font size=2 face="Courier New">Driver = org.hsqldb.jdbcDriver</font>
<br><font size=2 face="Courier New">TboxEngine = Default</font>
<br><font size=2 face="Courier New">DuplicateRemover = false</font>
<br>
<br>
<br>
<br>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br>
<br>
<br>
<br>
<br>
--=_alternative 0028C6D84825712D_=--
Re: Beginner EODM question [message #571888 is a reply to message #28070] Fri, 10 March 2006 07:55 Go to previous message
Eclipse UserFriend
Originally posted by: gordon.xx.com

The website of EODM at Eclipse.org is still under construction. Currently,
the only source to get documentation of EODM, and IODT (IBM Integrated
Ontology Development Toolkit), the toolkit that contains EODM, is
alphaWorks. You can find:
- sample code to manipulate EODM to creat ontologies, with instances
- sample code to store EODM into Minerva and use SPARQL to query

I'm not sure what version of IODT you are using. We are updating
alphaWorks with IODT v1.1.1, so please make sure that you are using the
latest version.
Previous Topic:[Announce] EMFT OCL 1.0.0M5 is available
Next Topic:[Announce] EMFT JET 1.0.0 I200603091046 is available
Goto Forum:
  


Current Time: Thu Sep 29 21:51:11 GMT 2022

Powered by FUDForum. Page generated in 0.02602 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top