3

Is it possible to parse an ontology given in manchester syntax such that it ends up as an owlready ontology-object.

This is what I found out so far:

  • Owlready itself can only import "NTriples, RDF/XML or OWL/XML format" (ref1).

  • Ontospy can (among other things) convert between these formats: ['xml', 'turtle', 'n3', 'nt', 'trix', 'rdfa'] (ref2).

  • rdflib has a function rdflib.extras.infixowl.manchesterSyntax(...) but which seems not to be documented very well and seems not to be applicable to a whole file (or str with several statements).

Is there any othter project I am missing, or is there an easy way to combine (someOf) these projects to parse an owl file in manchester syntax to an owlready ontology?

cknoll
  • 2,130
  • 4
  • 18
  • 34
  • 1
    the method in `rdflib` is for serialization, not for parsing. You can simply use Python code to create ontology objects in a DSL like in `owlready`. Long story short, if you don't find a parser then it doesn't work. So you would have to use some external API like the OWL API. You could also make use of a REST service, see http://mowl-power.cs.man.ac.uk:8080/converter/restful.jsp or https://www.ldf.fi/service/owl-converter/ - clearly, you could call this from Python as well, just would have to write the output to disk and then you could point `owlready` to the new file – UninformedUser Oct 26 '20 at 07:07
  • @UninformedUser Are you sure that the link [ref2](https://github.com/lambdamusic/Ontospy/blob/master/ontospy/core/rdf_loader.py#L34) refers to serialization and not to parsing? Because the module and the class are named "loader"(?). Anyway, using an REST service is a good idea. Nevertheless, I would prefer have a local solution. While the best would be "Python only" to minimize complexity, I guess that is currently not possible. Do you know how much effort it is to call OWL-API from the command line to convert between Manchester syntax and say RDF/XML? – cknoll Oct 26 '20 at 09:32
  • I'm confused now. I was referring to the `rdflib` method you mentioned - and this is just for serialization. Your link [ref2](https://github.com/lambdamusic/Ontospy/blob/master/ontospy/core/rdf_loader.py#L34) is for `ontospy` but this hasn't support for Manchester Syntax – UninformedUser Oct 26 '20 at 09:55
  • this API should work form CLI: https://github.com/sszuev/ont-converter – UninformedUser Oct 26 '20 at 10:03
  • The translation from Manchester syntax to OWL 2 Functional-Style Syntax (and likewise XML-style syntax) is mostly straightforward; see here: https://www.w3.org/2007/OWL/wiki/ManchesterSyntax#Informal_Description. You could use a simple library such as [pyparsing](https://pypi.org/project/pyparsing/) and implement it yourself, perhaps only for the relevant subset of OWL. – Lutz Prechelt Jun 20 '22 at 16:59

0 Answers0