Usage of ManchesterOWLSyntaxEditor outside Protege

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Usage of ManchesterOWLSyntaxEditor outside Protege

florinail
Hi,

I want to use the Manchester OWL Editor outside Protege and I'm not able to understand how that should work. I've tried  to use the org.semanticweb.owlapi library to create a simple example but nothing seems to work. What I want is to "ask a question" (i.e. to give an expression) and to receive a list of result from an ontology. Here is what I've tried and failed to succeed:

           OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
            File file  = new File("owl/test.owl");
         
            String text = "Pizza and hasBase some ThinAndCrispyBase";
            ManchesterOWLSyntaxEditorParser parser  = new ManchesterOWLSyntaxEditorParser(factory, text);
            parser.setDefaultOntology(ontology);
            parser.parseClassExpression();

When I'm running it I receive the following error:

org.semanticweb.owlapi.expression.ParserException: Encountered Pizza at line 1 column 1. Expected one of:
        Class name
        Object property name
        Data property name
        not
        inverse
        (
        {

        at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.createException(ManchesterOWLSyntaxEditorParser.java:3173)
        at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseNonNaryClassExpression(ManchesterOWLSyntaxEditorParser.java:630)
        at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseUnion(ManchesterOWLSyntaxEditorParser.java:514)
        at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseIntersection(ManchesterOWLSyntaxEditorParser.java:489)
        at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseClassExpression(ManchesterOWLSyntaxEditorParser.java:476)
        at Example3.main(Example3.java:104)

Where is the problem? The owl file is a copy of the pizza ontology. I've also tried with other ontologies (and questions) but didn't succeed.

Any help is kindly appreciated (since I have no idea what I'm doing wrong).

Thanks,

Ioana Lazar
         
           
           
Reply | Threaded
Open this post in threaded view
|

Re: Usage of ManchesterOWLSyntaxEditor outside Protege

Thomas Russ

On Jun 22, 2010, at 7:01 AM, florinail wrote:

>
> Hi,
>
> I want to use the Manchester OWL Editor outside Protege and I'm not  
> able to
> understand how that should work. I've tried  to use the
> org.semanticweb.owlapi library to create a simple example but  
> nothing seems
> to work. What I want is to "ask a question" (i.e. to give an  
> expression) and
> to receive a list of result from an ontology. Here is what I've  
> tried and
> failed to succeed:
>
>           OWLOntologyManager manager =
> OWLManager.createOWLOntologyManager();
>            File file  = new File("owl/test.owl");
>
>            String text = "Pizza and hasBase some ThinAndCrispyBase";
>            ManchesterOWLSyntaxEditorParser parser  = new
> ManchesterOWLSyntaxEditorParser(factory, text);
>            parser.setDefaultOntology(ontology);
>            parser.parseClassExpression();
>
> When I'm running it I receive the following error:
>
> org.semanticweb.owlapi.expression.ParserException: Encountered Pizza  
> at line
> 1 column 1. Expected one of:
> Class name
> Object property name
> Data property name
> not
> inverse
> (
> {
>
> ...
>
> Where is the problem? The owl file is a copy of the pizza ontology.  
> I've
> also tried with other ontologies (and questions) but didn't succeed.


It doesn't look like you ever loaded the OWL file.

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Usage of ManchesterOWLSyntaxEditor outside Protege

Timothy Redmond
In reply to this post by florinail

You need to set the OWLEntityChecker.  If you think about it, you have not told the OWLAPI enough to even parse "Pizza".  Should "Pizza" expand to the class with the name

http://co-ode.org/ontologies/pizza/pizza.owl#Pizza
  

or

http://www.co-ode.org/ontologies/pizza/2005/10/18/pizza.owl#Pizza

or something else.  The OWLEntityChecker allows you to specify this.  Determining the right prefix to use and whether a particular entity is a property or a class may involve you loading an ontology and getting the prefixes or something.  You also need to get the type associated with the name.   If the OWLEntityChecker does not know if Pizza is a class or a property then the OWLAPI will not be able to parse the expression

Pizza and hasBase some ThinAndCrispyBase
  
There is a GForge ticket out for this on the OWLAPI.

-Timothy

On 06/22/2010 07:01 AM, florinail wrote:
Hi,

I want to use the Manchester OWL Editor outside Protege and I'm not able to
understand how that should work. I've tried  to use the
org.semanticweb.owlapi library to create a simple example but nothing seems
to work. What I want is to "ask a question" (i.e. to give an expression) and
to receive a list of result from an ontology. Here is what I've tried and
failed to succeed:

           OWLOntologyManager manager =
OWLManager.createOWLOntologyManager();
            File file  = new File("owl/test.owl");
          
            String text = "Pizza and hasBase some ThinAndCrispyBase";
            ManchesterOWLSyntaxEditorParser parser  = new
ManchesterOWLSyntaxEditorParser(factory, text);
            parser.setDefaultOntology(ontology);
            parser.parseClassExpression();

When I'm running it I receive the following error:

org.semanticweb.owlapi.expression.ParserException: Encountered Pizza at line
1 column 1. Expected one of:
	Class name
	Object property name
	Data property name
	not
	inverse
	(
	{

	at
org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.createException(ManchesterOWLSyntaxEditorParser.java:3173)
	at
org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseNonNaryClassExpression(ManchesterOWLSyntaxEditorParser.java:630)
	at
org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseUnion(ManchesterOWLSyntaxEditorParser.java:514)
	at
org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseIntersection(ManchesterOWLSyntaxEditorParser.java:489)
	at
org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseClassExpression(ManchesterOWLSyntaxEditorParser.java:476)
	at Example3.main(Example3.java:104)

Where is the problem? The owl file is a copy of the pizza ontology. I've
also tried with other ontologies (and questions) but didn't succeed.

Any help is kindly appreciated (since I have no idea what I'm doing wrong).

Thanks,

Ioana Lazar
          
            
            
  


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Usage of ManchesterOWLSyntaxEditor outside Protege

Timothy Redmond
In reply to this post by florinail

One other thing, the algorithm used by the OWLEntityChecker for Protege involves reading an ontology (to be editted), making a hash map from short names for entities (e.g. Pizza) to the entity that they represent (e.g. the class named

http://co-ode.org/ontologies/pizza/pizza.owl#Pizza
  

and then using that map to determine the full name and type for any short name.

-Timothy

On 06/22/2010 07:01 AM, florinail wrote:
Hi,

I want to use the Manchester OWL Editor outside Protege and I'm not able to
understand how that should work. I've tried  to use the
org.semanticweb.owlapi library to create a simple example but nothing seems
to work. What I want is to "ask a question" (i.e. to give an expression) and
to receive a list of result from an ontology. Here is what I've tried and
failed to succeed:

           OWLOntologyManager manager =
OWLManager.createOWLOntologyManager();
            File file  = new File("owl/test.owl");
          
            String text = "Pizza and hasBase some ThinAndCrispyBase";
            ManchesterOWLSyntaxEditorParser parser  = new
ManchesterOWLSyntaxEditorParser(factory, text);
            parser.setDefaultOntology(ontology);
            parser.parseClassExpression();

When I'm running it I receive the following error:

org.semanticweb.owlapi.expression.ParserException: Encountered Pizza at line
1 column 1. Expected one of:
	Class name
	Object property name
	Data property name
	not
	inverse
	(
	{

	at
org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.createException(ManchesterOWLSyntaxEditorParser.java:3173)
	at
org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseNonNaryClassExpression(ManchesterOWLSyntaxEditorParser.java:630)
	at
org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseUnion(ManchesterOWLSyntaxEditorParser.java:514)
	at
org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseIntersection(ManchesterOWLSyntaxEditorParser.java:489)
	at
org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseClassExpression(ManchesterOWLSyntaxEditorParser.java:476)
	at Example3.main(Example3.java:104)

Where is the problem? The owl file is a copy of the pizza ontology. I've
also tried with other ontologies (and questions) but didn't succeed.

Any help is kindly appreciated (since I have no idea what I'm doing wrong).

Thanks,

Ioana Lazar
          
            
            
  


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Usage of ManchesterOWLSyntaxEditor outside Protege

Timothy Redmond

> Does anyone know which import should be used for the reasoner? I've tried
> with the one from "import org.mindswap.pellet.owlapi.Reasoner;" but I
> received the following error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/mindswap/pellet/KnowledgeBase
> at org.mindswap.pellet.owlapi.Reasoner.<init>(Reasoner.java:215)
> at Example3.main(Example3.java:106)
> Caused by: java.lang.ClassNotFoundException:
> org.mindswap.pellet.KnowledgeBase
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> ... 2 more
>
>
>   Thank you!

This exception suggests that you have included some but not all of the
needed jars on your classpath.  I suspect this because it is not saying
that it can't find the class org.mindswap.pellet.owlapi.Reasoner (in
fact it found that one) but it can't find a class on which this class
depends.

-Timothy



On 06/28/2010 03:57 AM, florinail wrote:

> Hi,
>
> I found a snippet code that does what I want, but I can't figure out which
> import to use for the reasoner.
>
> OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
>          OWLOntology ontology = manager.loadOntology( URI.create(
> "file:pizza.owl" ) );
>
>          ManchesterOWLSyntaxDescriptionParser parser =
>                  new ManchesterOWLSyntaxDescriptionParser(
>                          manager.getOWLDataFactory(),
>                          new ShortFormEntityChecker(
>                                  new BidirectionalShortFormProviderAdapter(
>                                          manager,
>                                          Collections.singleton( ontology ),
>                                          new SimpleShortFormProvider() ) ) );
>
>          Reasoner reasoner = new Reasoner( manager );
>          reasoner.loadOntology( ontology );
>
>          OWLDescription desc = parser.parse( "Pizza and hasTopping some
> SpicyTopping" );
>
>          System.out.println( reasoner.getSubClasses( desc ) );
>
> Does anyone know which import should be used for the reasoner? I've tried
> with the one from "import org.mindswap.pellet.owlapi.Reasoner;" but I
> received the following error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/mindswap/pellet/KnowledgeBase
> at org.mindswap.pellet.owlapi.Reasoner.<init>(Reasoner.java:215)
> at Example3.main(Example3.java:106)
> Caused by: java.lang.ClassNotFoundException:
> org.mindswap.pellet.KnowledgeBase
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> ... 2 more
>
>
>   Thank you!
>
> Ioana
>    

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Usage of ManchesterOWLSyntaxEditor outside Protege

Matthew Horridge
Just to add to the discussion.....

There are some examples here that might be of use to you:

http://owlapi.svn.sourceforge.net/viewvc/owlapi/v3/trunk/examples/src/main/java/org/coode/owlapi/examples/dlquery/

In particular:

http://owlapi.svn.sourceforge.net/viewvc/owlapi/v3/trunk/examples/src/main/java/org/coode/owlapi/examples/dlquery/DLQueryParser.java?revision=1458&view=markup

Cheers,

Matthew

On 29 Jun 2010, at 16:36, Timothy Redmond wrote:

>
>> Does anyone know which import should be used for the reasoner? I've tried
>> with the one from "import org.mindswap.pellet.owlapi.Reasoner;" but I
>> received the following error:
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/mindswap/pellet/KnowledgeBase
>> at org.mindswap.pellet.owlapi.Reasoner.<init>(Reasoner.java:215)
>> at Example3.main(Example3.java:106)
>> Caused by: java.lang.ClassNotFoundException:
>> org.mindswap.pellet.KnowledgeBase
>> at java.net.URLClassLoader$1.run(Unknown Source)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>> ... 2 more
>>
>>
>>  Thank you!
>
> This exception suggests that you have included some but not all of the needed jars on your classpath.  I suspect this because it is not saying that it can't find the class org.mindswap.pellet.owlapi.Reasoner (in fact it found that one) but it can't find a class on which this class depends.
>
> -Timothy
>
>
>
> On 06/28/2010 03:57 AM, florinail wrote:
>> Hi,
>>
>> I found a snippet code that does what I want, but I can't figure out which
>> import to use for the reasoner.
>>
>> OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
>>         OWLOntology ontology = manager.loadOntology( URI.create(
>> "file:pizza.owl" ) );
>>
>>         ManchesterOWLSyntaxDescriptionParser parser =
>>                 new ManchesterOWLSyntaxDescriptionParser(
>>                         manager.getOWLDataFactory(),
>>                         new ShortFormEntityChecker(
>>                                 new BidirectionalShortFormProviderAdapter(
>>                                         manager,
>>                                         Collections.singleton( ontology ),
>>                                         new SimpleShortFormProvider() ) ) );
>>
>>         Reasoner reasoner = new Reasoner( manager );
>>         reasoner.loadOntology( ontology );
>>
>>         OWLDescription desc = parser.parse( "Pizza and hasTopping some
>> SpicyTopping" );
>>
>>         System.out.println( reasoner.getSubClasses( desc ) );
>>
>> Does anyone know which import should be used for the reasoner? I've tried
>> with the one from "import org.mindswap.pellet.owlapi.Reasoner;" but I
>> received the following error:
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/mindswap/pellet/KnowledgeBase
>> at org.mindswap.pellet.owlapi.Reasoner.<init>(Reasoner.java:215)
>> at Example3.main(Example3.java:106)
>> Caused by: java.lang.ClassNotFoundException:
>> org.mindswap.pellet.KnowledgeBase
>> at java.net.URLClassLoader$1.run(Unknown Source)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>> ... 2 more
>>
>>
>>  Thank you!
>>
>> Ioana
>>  
>
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Usage of ManchesterOWLSyntaxEditor outside Protege

kvlinden
Matthew Horridge <matthew.horridge <at> cs.man.ac.uk> writes:

>
> Just to add to the discussion.....
>
> There are some examples here that might be of use to you:
>
>
http://owlapi.svn.sourceforge.net/viewvc/owlapi/v3/trunk/examples/src/main/java/
org/coode/owlapi/examples/dlquery/
>
> In particular:
>
>
http://owlapi.svn.sourceforge.net/viewvc/owlapi/v3/trunk/examples/src/main/java/
org/coode/owlapi/examples/dlquery/DLQueryParser.java?revision=1458&view=markup
>
> Cheers,
>
> Matthew


Matthew,

Thanks for this code reference. I'm doing a similar thing (i.e., building my own
version of Protege's DL Query in a Java/OWLAPI application) but have found that
the code you link above fails to parse numeric class expressions as I would
expect. For example, Protege 4.1.0-213's DL Query interface parses the following
expression properly:

Person and (hasAge some xsd:integer[>= 14])

but the DLQueryParser#parseClassExpression() linked above throws an error
(copied below) when parsing it. I recall getting this error with an earlier
version of Protege at one point. Could the example code you link have an old bug
that has been fixed in the current version of Protege?

many thanks,

keith

The runtime error:

Exception in thread "main"
org.semanticweb.HermiT.datatypes.UnsupportedFacetException: The
'http://www.w3.org/2001/XMLSchema#minInclusive' facet takes only numbers as
values when used on a datatype derived from owl:real, but the ontology contains
a datatype restriction
org.semanticweb.HermiT.datatypes.owlreal.OWLRealDatatypeHandler@ae8af4 where 14
is not a number.

        at
org.semanticweb.HermiT.datatypes.owlreal.OWLRealDatatypeHandler.validateDatatype
Restriction(Unknown Source)
        at
org.semanticweb.HermiT.datatypes.DatatypeRegistry.validateDatatypeRestriction(Un
known Source)
        at
org.semanticweb.HermiT.structural.OWLClausification$DataRangeConverter.visit(Unk
nown Source)
        at
uk.ac.manchester.cs.owl.owlapi.OWLDatatypeRestrictionImpl.accept(OWLDatatypeRest
rictionImpl.java:108)
        at
org.semanticweb.HermiT.structural.OWLClausification$DataRangeConverter.convertDa
taRange(Unknown Source)
        at
org.semanticweb.HermiT.structural.OWLClausification$DataRangeConverter.visit(Unk
nown Source)
        at
uk.ac.manchester.cs.owl.owlapi.OWLDataComplementOfImpl.accept(OWLDataComplementO
fImpl.java:89)
        at
org.semanticweb.HermiT.structural.OWLClausification$DataRangeConverter.convertDa
taRange(Unknown Source)
        at
org.semanticweb.HermiT.structural.OWLClausification$NormalizedAxiomClausifier.vi
sit(Unknown Source)
        at
uk.ac.manchester.cs.owl.owlapi.OWLDataAllValuesFromImpl.accept(OWLDataAllValuesF
romImpl.java:65)
        at org.semanticweb.HermiT.structural.OWLClausification.clausify(Unknown
Source)
        at org.semanticweb.HermiT.Reasoner.createDeltaDLOntology(Unknown Source)
        at org.semanticweb.HermiT.Reasoner.getTableau(Unknown Source)
        at org.semanticweb.HermiT.Reasoner.getHierarchyNode(Unknown Source)
        at org.semanticweb.HermiT.Reasoner.getSuperClasses(Unknown Source)
        at
org.coode.owlapi.examples.dlquery.DLQueryEngine.getSuperClasses(DLQueryEngine.ja
va:51)
        at
org.coode.owlapi.examples.dlquery.DLQueryPrinter.askQuery(DLQueryPrinter.java:46
)
        at
org.coode.owlapi.examples.dlquery.DLQueryExample.main(DLQueryExample.java:57)


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Usage of ManchesterOWLSyntaxEditor outside Protege

Timothy Redmond
On 11/26/2010 03:11 PM, Keith Vander Linden wrote:
> Person and (hasAge some xsd:integer[>= 14])
>
> but the DLQueryParser#parseClassExpression() linked above throws an error
> (copied below) when parsing it. I recall getting this error with an earlier
> version of Protege at one point. Could the example code you link have an old bug
> that has been fixed in the current version of Protege?

I remember this bug and it has been recently fixed in Protege 4.  Until
this is resolved, you can use the version of the owl api
(org.semanticweb.owl.owlapi.jar) that comes with the latest Protege.

I found the lines of code in the OWL api that caused this problem but
somehow neglected to write a GForge ticket for this issue.  I think that
I had some doubts about this bug.  I still have these doubts but I have
created a GForge ticket [1] for this anyway.  I figure that Ignazio and
Matthew will know the right fix.

-Timothy

[1] https://sourceforge.net/tracker/?func=detail&aid=3121903&group_id=90989&atid=595534

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Usage of ManchesterOWLSyntaxEditor outside Protege

kvlinden
Many thanks.

I was picking up an older version of the owlapi jar from the hermit 1.3.1 jar.

keith