creating individuals and checking inherited and reasoned properties

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

creating individuals and checking inherited and reasoned properties

davideps
Hi folks. I'm have a few questions about using owlready2. Please find two files attached. The PROTEGE export loads fine. The FLUENT export does not.

1. I load the PROTEGE export into the variable "onto". list(onto.classes()) shows the first class to be "ontorion.com.Wolf". How can I use this class's name to create an individual wolf? This name does not appear to exist in Python's standard namespace (autocomplete does find anything beginning with "ontorion")

2. Every wolf is a member of the class LargeCarnivore. How can I check that the new individual is a LargeCarnivore?

3. Every animal has a property called "hasThreatLevel". How can I check that the new individual has such a property and check its value?

4. Every "port" is adjacent-to a "sea". The ontology includes an instance of a port called "AshwaterPort". How can I check if this port is adjacent-to a sea? Does this require using the reasoner?

5. Finally, I use FLUENT's controlled English editor to create my ontology. Its exported file produces the error below in owlready2. Luckily, Protege can read the file and export a usable file. Is owlready2 being especially strict or does FLUENT produce an invalid OWL file?

Thank you,
-david


>>> onto = get_ontology("D:\\projects\\Programming\\Python\\Interactive_Fiction\\fantasy_ontology_FLUENT_export_01.owl").load()
Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\owlready2\driver.py", line 147, in parse
    s,p,o = splitter.split(line[:-3], 2)
ValueError: not enough values to unpack (expected 3, got 1)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python37\lib\site-packages\owlready2\namespace.py", line 733, in load
    try:     new_base_iri = self.graph.parse(fileobj, default_base = self.base_iri, **args)
  File "C:\Program Files\Python37\lib\site-packages\owlready2\driver.py", line 181, in parse
    raise OwlReadyOntologyParsingError("NTriples parsing error (or unrecognized file format) in %s, line %s." % (getattr(f, "name", getattr(f, "url", "???")), current_line)) from e
owlready2.base.OwlReadyOntologyParsingError: NTriples parsing error (or unrecognized file format) in D:\projects\Programming\Python\Interactive_Fiction\fantasy_ontology_FLUENT_export_01.owl, line 531.

fantasy_ontology_FLUENT_export_01.owlfantasy_ontology_PROTEGE_export_01.owl
Reply | Threaded
Open this post in threaded view
|

Re: creating individuals and checking inherited and reasoned properties

Jiba
Administrator
1) use IRIS["http://ontorion.com/Wolf"] or create a namespace for "http://ontorion.com/" (see doc)

2) use the Python function isinstance()

3) individual.hasThreatLevel

4) Whether a reasoner is required or not depends on whether inferrences are required to guess the adjacency value -- it depends on the content of your ontology.

5) The FLUENT file starts by unicode character "\ufeff", just before XML header "<?xml...". As a consequence, it is not recognized as an XML file and not parsed correctly (XML header must appear first I think). Then, classes are not defined in the ontology, just used, thus they do not appear in classes() and they may not be recognized as classes (but e.g. as individual).

I've added more tolerancy on "\ufeff" and not defined class in the development version of Owlready (on BitBucket).
Reply | Threaded
Open this post in threaded view
|

Re: creating individuals and checking inherited and reasoned properties

davideps
Thank you. I'll look into how to create a namespace. I think that might be what is confusing me. Thank you for updating the developer code as well.

On Wed, May 29, 2019 at 1:49 PM Jiba [via Owlready] <[hidden email]> wrote:
1) use IRIS["http://ontorion.com/Wolf"] or create a namespace for "http://ontorion.com/" (see doc)

2) use the Python function isinstance()

3) individual.hasThreatLevel

4) Whether a reasoner is required or not depends on whether inferrences are required to guess the adjacency value -- it depends on the content of your ontology.

5) The FLUENT file starts by unicode character "\ufeff", just before XML header "<?xml...". As a consequence, it is not recognized as an XML file and not parsed correctly (XML header must appear first I think). Then, classes are not defined in the ontology, just used, thus they do not appear in classes() and they may not be recognized as classes (but e.g. as individual).

I've added more tolerancy on "\ufeff" and not defined class in the development version of Owlready (on BitBucket).


If you reply to this email, your message will be added to the discussion below:
http://owlready.8326.n8.nabble.com/creating-individuals-and-checking-inherited-and-reasoned-properties-tp1100p1109.html
To unsubscribe from creating individuals and checking inherited and reasoned properties, click here.
NAML