简体   繁体   中英

Build an OWL file with JENA

My work requires a construction of ontologies modules. For this I need to construct owl files to contain those ontologies. My input is an xml file with parsed and splitted sentences.

<Subject> A tumor </Subject> 
<Verb> is </Verb> 
<Object> an abnormal growth </Object> 
</sentence> 
<sentence> 
<Subject> A kidney tumor </Subject> 
<Verb> is </Verb> 
<Object> an abnormal growth </Object> 

What I need to do now is:

  • convert "subject" and "object" into OntClass
  • convert "verb" into a transitive property between "obj" and "sub"

I am new on the ontology domain, may be those are basic questions, but I am struggling with the creation of those files, and especially with the transitive property.

Any help is welcome.

To create an OntClass , you simply need to call OntModel.createClass( uri ) . Of course, that then leaves the question of which uri you should use. You'll need a namespace, something of the form http://yourcompany.com/ontology/diagnosis# ; ideally this namespace will correspond to a web address where your ontology document can be retrieved.

Then you'll need an algorithm for converting a phrase like 'A tumor' into a class name. This could be quite simple:

  • remove prefixes such as definite and indefinite articles (a, an, the)
  • remove spaces and use CamelCase to denote word boundaries

Then the uri will be the concatenation of the namespace and the converted name.

Creating transitive properties is also straightforward ( OntModel.createTransitiveProperty() ), but in the sample that you show, it appears that you're actually talking about the sub-class relationship between classes. If it is always true that all ns:KidneyTumor instances are also in the set of ns:AbnormalGrowth instances, then your <Verb>is</Verb> corresponds to the existing RDF property rdfs:subClassOf . Of course, if that relationship is more subtle (eg may be conditionally or probabilistically true), then you'll need a different relationship with your particular semantics.

As for reading the XML file, there are many tutorials on the web or questions on Stackoverflow to help with that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM