4

I have an OWL class Verse wich has a data property named hasContent. Property's range is string. Using DL query, e.g. Verse and hasContent "complete text of a verse", I can find the verse that contains the specified text. I now want to find all intances of verses that contain some word.

Can regular expressions be used in Protege OWL query? Is there any example? Or I need to use the more complicated query language, SPARQL?

user1794211
  • 65
  • 1
  • 6

2 Answers2

2

You can use XSD facets directly within the OWL Manchester syntax (the syntax what you use in Protege). With a facet you can achieve some of the things you can do with a regex, via the pattern construct. The implementation is reasoner-specific, some it might work sometimes and sometimes not :-/ s an Some links to learn more about it:

Community
  • 1
  • 1
loopasam
  • 3,027
  • 2
  • 21
  • 22
0

SPARQL is the query language for RDF and there is a reason for it. If you use plain regex (withou SPARQL) you would not be able to define your target (instances, classes, properties etc) and you would not exploit the benefits of using an ontology. Regular expressions are fine for plain texts, but an ontology is not a plain text and you shouldn't handle it as such. I would strongly suggest using SPARQL, which already has included regular expressions when it comes to restricting string values.

Another solution, (I would not by anyway suggest it) is to export your target ontology as an RDF/XML document and apply regular expressions search on it as if it was a simple document.

Hope I helped!

Pantelis Natsiavas
  • 5,293
  • 5
  • 21
  • 36
  • To use SPARQL in querying OWL ontologies though, you have to know how OWL is encoded in RDF, and there can be some variation in that. It really is beneficial to be able to use the DL query that's provided in Protégé, or to use an OWL specific API such as the OWLAPI. As [loopasam's answer](http://stackoverflow.com/a/21231025/1281433) pointed out, xsd facets can use the pattern construction, so there _is_ the possibility of doing regex queries without needing to use SPARQL. – Joshua Taylor Jan 20 '14 at 15:48