I have just written a small program to list the classes on SSN and SOSA.
Here is my code; ssn = get_ontology("http://www.w3.org/ns/ssn").load() sosa = get_ontology("http://www.w3.org/ns/sosa").load() print(ssn.classes) print(sosa.classes) However, the program only prints some of the classes listed in Semantic Sensor Network Ontology. Here is the Link for more information about classes in ssn and sosa. Just wondering if this behaviour is normal? |
Administrator
|
I got 16 and 11 classes when loading SOSA and SSN, and that corresponds to the number of "<owl:Class" in the RDF file, so it seems ok.
Could you give me an example of a missing class? |
This post was updated on .
This works when I load files which are saved locally. Otherwise, it gives me an error.
I tried following program to instantiate a sensor from sosa ontology. from owlready2 import * onto = get_ontology("http://domain.com/test_sensor_onto") ssn = get_ontology("file://C:\\Users\\abc\\Desktop\\Excel_parser\\OWL-xml_version\\ssn.owl").load() sosa = get_ontology("file://C:\\Users\\abc\\Desktop\\Excel_parser\\OWL-xml_version\\sosa.owl").load() onto.imported_ontologies.append(ssn) onto.imported_ontologies.append(sosa) sensor = sosa.Sensor("mySensor", namespace = onto) onto.save("test_sensor_onto.owl") However, I am getting an error saying that sensor = sosa.Sensor("mySensor", namespace = onto) TypeError: 'NoneType' object is not callable Whereas, Sensor is one of the classes of sosa ontology. Any idea why this is happening? |
Administrator
|
I fixed a big in class IRI in ontology with name ending by a / (for example http://www.w3.org/ns/sosa/Sensor instead of http://www.w3.org/ns/sosa.owl#Sensor).
This resulted in Class IRI like http://www.w3.org/ns/sosa/#Sensor, and thus sosa.Sensor was not found. Could you try again with the Mercurial development version of Owlready2? By the way, you need a local copy because the ontology IRI point toward an ontology in Turtle format, not in OWL. Jiba |
Many thanks for all your efforts.
Any ideas on where to find and how to use Mercurial development version of Owlready2? Regards, |
Administrator
|
Hello,
Mercurial development version is hosted on Bitbucket: https://bitbucket.org/jibalamy/owlready2 You can get it with the hg command line program, or download a zip file at https://bitbucket.org/jibalamy/owlready2/downloads/ Best regards, Jean-Baptiste Lamy MCF, LIMICS, Université Paris 13 |
Hi,
I downloaded the zip file and extracted its contents, and saved the folder as owlready12 in my working directory. Here is my testing code. from owlready12 import * import glob onto_path.append("/C:\\Excel_parser") onto1 = get_ontology("file:///C:\\Excel_parser\\test_onto.owl") onto1.imported_ontologies = [] for i in glob.glob("C:\\Excel_parser\\OWL-xml_version\\*.owl"): i = get_ontology("file://%s"%i).load() onto1.imported_ontologies.append(i) print("saving file") onto1.save("onto2.owl") However, it is giving me an error from owlready12 import * File "C:\Excel_parser\Onto_test\owlready12\__init__.py", line 94, in <module> del owl_world._props["Property"] KeyError: 'Property' Any ideas? |
Administrator
|
Hi,
You CANNOT name the directory "owlready12"; it must be named "owlready" because the various modules expect this name for loading the package. Best regards, Jiba |
Hello,
I renamed it to owlready, however, this also expects my code to be in the owlready folder. Otherwise, it will give the same error. Now there are other errors. I am trying to do this; from owlready import * onto = get_ontology("http://domain.com/test_sensor_onto") onto.imported_ontologies = [] #sosa = get_ontology("https://www.w3.org/ns/sosa").load() #ssn = get_ontology("https://www.w3.org/ns/ssn").load() sosa = get_ontology("file://sosa.owl").load() ssn = get_ontology("file://ssn.owl").load() onto.imported_ontologies.append(sosa) onto.imported_ontologies.append(ssn) sensor = ssn.Sensor("mySensor", namespace = onto) onto.save("test_sensor_onto2.owl") I have tried using url to load ontologies but it gives other errors. For the above code, I am getting the attached errors; |
Administrator
|
I slightly modified your script (owlready => owlready2, ssn.Sensor => sosa.Sensor):
from owlready2 import * onto = get_ontology("http://domain.com/test_sensor_onto") onto.imported_ontologies = [] #sosa = get_ontology("https://www.w3.org/ns/sosa").load() #ssn = get_ontology("https://www.w3.org/ns/ssn").load() sosa = get_ontology("file://sosa.owl").load() ssn = get_ontology("file://ssn.owl").load() onto.imported_ontologies.append(sosa) onto.imported_ontologies.append(ssn) sensor = sosa.Sensor("mySensor", namespace = onto) onto.save("test_sensor_onto2.owl") and it works perfectly on my computer. It produced the following ontology: <?xml version="1.0"?> <rdf:RDF xml:base="http://domain.com/test_sensor_onto" xmlns="http://domain.com/test_sensor_onto#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:sosa="http://www.w3.org/ns/sosa/"> <owl:Ontology rdf:about="http://domain.com/test_sensor_onto"> <owl:imports rdf:resource="http://www.w3.org/ns/sosa"/> <owl:imports rdf:resource="http://www.w3.org/ns/ssn"/> </owl:Ontology> <sosa:Sensor rdf:about="#mySensor"> <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/> </sosa:Sensor> </rdf:RDF> Are you sure you are using the development version of Owlready 2? |
Hi,
I think I am not doing something correctly; I have tried following two options; 1) I downloaded the development version zip file from https://bitbucket.org/jibalamy/owlready2/downloads/ 2) I extracted it and saved it as "owlready" folder 3) I then added my ontology files and python program (the one above) in the same folder (i.e. owlready). 4) I went to that directory and did python filename.py But this is not working for me. I also tried doing the following; 1) Extracted the development version downloaded from https://bitbucket.org/jibalamy/owlready2/downloads/ 2) uninstalled previously installed owlready versions 3) went to the extracted directory and did python setup.py develop but now it is giving me the error that No module named owlready2 any ideas on what am I doing wrong? Thanks |
Dear Jiba,
Any recommendation on the above, please? How to properly setup development version? Regards, |
I installed the development version using simply
python setup.py install You might give it a try. |
Thanks, it did install but I am still getting the same error again that
sensor =sosa.Sensor("mySensor", namespace = onto) TypeError: 'NoneType' object is not callable I copied Jiba's code example to test this. Any ideas? |
Administrator
|
Hello,
Are you sure you are using the development version? Maybe you should uninstall the other version, and also verify with: import owlready2 print(owlready2.__file__) Best regards, Jean-Baptiste Lamy MCF, LIMICS, Université Paris 13 |
Hello,
I think I am am using the development. Could you please take a look at the steps that I have mentioned in one of the previous posts to install development version of owlready2? |
Administrator
|
Hello,
I've just made a new release of Owlready, including the bugfixes that were in the development version. It will probably be easier to install! Best regards, jiba |
Free forum by Nabble | Edit this page |