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 callOntModel.createClass( uri ). Of course, that then leaves the question of whichuriyou should use. You’ll need a namespace, something of the formhttp://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:
Then the
uriwill 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 allns:KidneyTumorinstances are also in the set ofns:AbnormalGrowthinstances, then your<Verb>is</Verb>corresponds to the existing RDF propertyrdfs:subClassOf. Of course, if that relationship is more subtle (e.g. 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.