about INDIRECT_relation (closed)

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

about INDIRECT_relation (closed)

William
This post was updated on .
Hi~

Why do I have c.INDIRECT_love == [society.Dog], when c.love == []? Moreover, society.Dog is a concept, instead of individual, what is INDIRECT_love really meaning?

In physics, if c loves something indirectly, it most love something directly. There should be something delivering its love to others.

with society:
    class Person(Thing):
        pass

    class Cat(Thing):
        pass

    class Dog(Thing):
        pass

    # class love_(Dog >> Cat):
    #     pass

    class love(Cat >> Dog):
        pass

    p = Person('p')
    c = Cat('c')
    d=Dog('d')
 
    Cat.is_a.append(love.some(Dog))

close_world(society)
sync_reasoner(debug=1)

print(c.love)
print(c.INDIRECT_love)

# []
# [society.Dog]

=====================================
I hope that you can solve the following two problems in passing.

PS: why I got the following error, if de-comment the class love_
* Owlready2 * Running HermiT...
    java -Xmx2000M -cp /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/hermit:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/hermit/HermiT.jar org.semanticweb.HermiT.cli.CommandLine -c -O -D -I file:////var/folders/md/8kgtqqz12j94hbcvhqz0w7gw0000gp/T/tmpq8m667au
* Owlready2 * HermiT took 0.7114648818969727 seconds
* Owlready * Equivalenting: None society.love_
Traceback (most recent call last):
  File "/Users/william/Folders/ontology/test/base.py", line 34, in <module>
    sync_reasoner(debug=1)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/reasoning.py", line 199, in sync_reasoner_hermit
    _apply_reasoning_results(world, ontology, debug, new_parents, new_equivs, entity_2_type)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/reasoning.py", line 373, in _apply_reasoning_results
    concept1.equivalent_to._append(concept2)
AttributeError: 'NoneType' object has no attribute 'equivalent_to'
[Finished in 0.9s with exit code 1]
[cmd: ['python3', '-u', '/Users/william/Folders/ontology/test/base.py']]
[dir: /Users/william/Folders/ontology/test]
[path: /Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin]

PSS:
If I define
class love(Cat >> Dog):
        inverse_property=love_
then get OwlReadyInconsistentOntologyError

* Owlready2 * Running HermiT...
    java -Xmx2000M -cp /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/hermit:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/hermit/HermiT.jar org.semanticweb.HermiT.cli.CommandLine -c -O -D -I file:////var/folders/md/8kgtqqz12j94hbcvhqz0w7gw0000gp/T/tmpnl6l4c3q
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/reasoning.py", line 133, in sync_reasoner_hermit
    output = subprocess.check_output(command, stderr = subprocess.STDOUT)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['java', '-Xmx2000M', '-cp', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/hermit:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/hermit/HermiT.jar', 'org.semanticweb.HermiT.cli.CommandLine', '-c', '-O', '-D', '-I', 'file:////var/folders/md/8kgtqqz12j94hbcvhqz0w7gw0000gp/T/tmpnl6l4c3q']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/william/Folders/ontology/test/base.py", line 34, in <module>
    sync_reasoner(debug=1)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/reasoning.py", line 136, in sync_reasoner_hermit
    raise OwlReadyInconsistentOntologyError()
owlready2.base.OwlReadyInconsistentOntologyError
[Finished in 0.9s with exit code 1]
[cmd: ['python3', '-u', '/Users/william/Folders/ontology/test/base.py']]
[dir: /Users/william/Folders/ontology/test]
[path: /Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin]
Reply | Threaded
Open this post in threaded view
|

Re: about INDIRECT_relation

Jiba
Administrator
Hello,

society.Dog appears in c.INDIRECT_love because of the following line: Cat.is_a.append(love.some(Dog))

Through inheritance, c inherit the restriction, which is translated as a relation to a class in Owlready.


I do not obtain the errors you pasted; could you send me the entire script?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: about INDIRECT_relation

William
Following is the whole script.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from owlready2 import *
# import pathlib
# PATH = pathlib.Path("~/Folders/ontology/test/base").expanduser()
# onto_path.append(PATH)
test = get_ontology("http://test.org/test.owl")


with test:
    class Person(Thing):
        pass

    class Cat(Thing):
        pass

    class Dog(Thing):
        pass

    class love_(Dog >> Cat):
        pass


    # class love(Cat >> Dog):
    #     inverse_property=love_

    class love(Cat >> Dog):
        pass

    p = Person('p')
    c = Cat('c')
    d=Dog('d')
 
    Cat.is_a.append(love.some(Dog))

close_world(test)
sync_reasoner(debug=1)

print(c.love)
print(c.INDIRECT_love)




Reply | Threaded
Open this post in threaded view
|

Re: about INDIRECT_relation

Jiba
Administrator
Hi,

The problem is the following: you close the entire ontology. Thus, it closes love_. Because no love_ relation is asserted in the ontology, the reasoner deduce that love_ is a descendant of bottomObjectProperty, but bottomObjectProperty was not implemented in Owlready.

I added bottomObjectProperty and bottomDataProperty in the developement version, so it no longer crash.

However, in your example, you probably don't want to close everything.

Jiba