Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catching instances of owl:Nothing #71

Closed
Demirrr opened this issue Sep 18, 2024 · 5 comments
Closed

Catching instances of owl:Nothing #71

Demirrr opened this issue Sep 18, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Demirrr
Copy link
Member

Demirrr commented Sep 18, 2024

from owlapy.owl_reasoner import SyncReasoner
from owlapy.class_expression import OWLClass
from owlapy.owl_individual import OWLNamedIndividual
from owlapy.iri import IRI

ontology_path = "KGs/Family/father.owl"
hermit  = SyncReasoner(ontology=ontology_path, reasoner = "HermiT")

thing=OWLClass(IRI('http://www.w3.org/2002/07/owl#', 'Thing'))
nothing=OWLClass(IRI('http://www.w3.org/2002/07/owl#', 'Nothing'))
print(nothing.iri.as_str())
print(hermit.instances(nothing))

Throws the following error

Traceback (most recent call last):
File "ManchesterOWLSyntaxClassExpressionParser.java", line 53, in org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxClassExpressionParser.parse
Exception: Java Exception

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

Traceback (most recent call last):
  File "/home/cdemir/Desktop/Softwares/owlapy/temp.py", line 12, in <module>
    print(hermit.instances(nothing))
  File "/home/cdemir/Desktop/Softwares/owlapy/owlapy/owl_reasoner.py", line 1233, in instances
    mapped_ce=self.mapper.map_(ce)
  File "/home/cdemir/anaconda3/envs/temp_owlapy/lib/python3.10/functools.py", line 926, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/home/cdemir/Desktop/Softwares/owlapy/owlapy/owlapi_mapper.py", line 154, in _
    return self.parser.parse(owl_expression_to_manchester(e))
org.semanticweb.owlapi.manchestersyntax.renderer.org.semanticweb.owlapi.manchestersyntax.renderer.ParserException: org.semanticweb.owlapi.manchestersyntax.renderer.ParserException: Encountered Nothing at line 1 column 1. Expected one of:
	Class name
	Object property name
	Data property name
	inverse
	not
	(
	{
@Demirrr Demirrr added the bug Something isn't working label Sep 18, 2024
@Demirrr
Copy link
Member Author

Demirrr commented Sep 18, 2024

Using nothing doesn't seem to work

# hasChild a nothing.
assert hermit.instances(OWLObjectSomeValuesFrom(property=hasChild, filler=nothing))==eval("{OWLNamedIndividual(IRI('http://example.com/father#', 'michelle')), OWLNamedIndividual(IRI('http://example.com/father#', 'heinz')))}")

@alkidbaci
Copy link
Collaborator

This got fixed. There was a Manchester rendering & parsing issue for owl:Nothing.
Btw you can use OWLNothing and OWLThing instead of declaring them from scratch.

from owlapy.class_expression import OWLNothing, OWLThing

@Demirrr
Copy link
Member Author

Demirrr commented Sep 18, 2024

Great thank you!

@Demirrr
Copy link
Member Author

Demirrr commented Sep 19, 2024

hermit.instances(OWLNothing.get_object_complement_of()) doesnt seem to work :(

@alkidbaci
Copy link
Collaborator

This is now fixed fixed! PR: #73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants