Extracting properties with different namespaces

Posted by June27 on
URL: http://owlready.306.s1.nabble.com/Extracting-properties-with-different-namespaces-tp963.html

Hi,
I have an ontology that contains different namespaces, and I'm trying to iterate through all classes and extract specific properties from each class. An example class of my ontology looks like:


    <owl:Class rdf:about="&obo;CHEBI_28260">
        <oboInOwl:hasRelatedSynonym>galactose, d-</oboInOwl:hasRelatedSynonym>
        <rdfs:label rdf:datatype="&xsd;string">galactose</rdfs:label>
    </owl:Class>


So in the case above, I'm trying to extract rdfs:label and oboInOwl:hasRelatedSynonym with the following code:

my_world = World()
onto = my_world.get_ontology(infile).load()

for i in onto.classes():
    label1 = i.label
    synonyms1 = i.hasRelatedSynonym
    ...

This code executes without error but no synonyms are extracted. I assume this is due to the different namespace because if I replace all 'oboInOwl' in the ontology with 'rdf', then I get an AttributeError ("'hasRelatedSynonym' property is not defined."), I assume because "hasRelatedSynonym" is not defined in the rdfs namespace.

So my question is, is there a way to indicate a specific namespace within my for loop?

Thanks for any help.