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

EvoLearner Example Broken #475

Closed
heindorf opened this issue Nov 7, 2024 · 3 comments
Closed

EvoLearner Example Broken #475

heindorf opened this issue Nov 7, 2024 · 3 comments
Assignees

Comments

@heindorf
Copy link
Member

heindorf commented Nov 7, 2024

I tried to run python concept_learning_with_evolearner.py in the latest ontolearn version (0.80). However, I get the error

Traceback (most recent call last):
  File "/home/heindorf/git/Ontolearn/examples/concept_learning_with_evolearner.py", line 61, in <module>
    model.save_best_hypothesis(n=3, path='Predictions_{0}'.format(str_target_concept))
  File "/home/heindorf/git/Ontolearn/ontolearn/base_concept_learner.py", line 383, in save_best_hypothesis
    ontology.save(IRI.create(path + '.owl'))
  File "/home/heindorf/.conda/envs/ontolearn/lib/python3.10/site-packages/owlapy/iri.py", line 89, in create
    return IRI(string[0:index], string[index:])
  File "/home/heindorf/.conda/envs/ontolearn/lib/python3.10/site-packages/owlapy/iri.py", line 20, in __call__
    _temp = super().__call__(*args, **kwargs)
  File "/home/heindorf/.conda/envs/ontolearn/lib/python3.10/site-packages/owlapy/iri.py", line 46, in __init__
    assert namespace[-1] in ("/", ":", "#"), "It should be a valid IRI based on /, :, and #"
IndexError: string index out of range

The problem seems to be in the line model.save_best_hypothesis(n=3, path='Predictions_{0}'.format(str_target_concept))

@alkidbaci
Copy link
Collaborator

This is related with a change in owlapy where the standard to save an ontology is by using an IRI and what the error is indicating is that Predictions_{str_target_concept} is not a valid IRI because it does not contain one of ("/", ":", "#"). Now its true that the argument name path is a bit misleading but the path should be a valid iri in string format which basically refers to the saving filename. In this case we add a "./" before the name so it will be considered a valid IRI and filepath at the same time, i.e. (./Predictions_{str_target_concept}. These changes are recent and the example is apparently not updated.
Maybe we can alter the standard a bit to be less restrictive

@heindorf
Copy link
Member Author

heindorf commented Nov 7, 2024

By the way, the same issue occurs for CELOE:

model.save_best_hypothesis(n=3, path='Predictions_{0}'.format(str_target_concept))

@Demirrr
Copy link
Member

Demirrr commented Nov 7, 2024

Fixed with #477
We created a text for each example so that the examples will not be broken, see
https://github.com/dice-group/Ontolearn/blob/develop/tests/test_example_celoe.py
https://github.com/dice-group/Ontolearn/blob/develop/tests/test_evolearner.py

@Demirrr Demirrr closed this as completed Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants