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

[duplicate] return classes with proper ontological hierarchy #853 #13

Closed
adhamhashibon opened this issue Jul 18, 2023 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@adhamhashibon
Copy link
Contributor

simphony/simphony-osp#853

the superclasses attribute returns the classes in random (alphabetical?) order, but should be in proper hierarchical order as it will convey more added value in applications.

e.g., superclasses of a citizen is now:

frozenset({<OntologyClass: City [https://www.simphony-osp.eu/city#City>,](https://www.simphony-osp.eu/city#City%3E,)
           <OntologyClass: Geographical Place [https://www.simphony-osp.eu/city#GeographicalPlace>,](https://www.simphony-osp.eu/city#GeographicalPlace%3E,)
           <OntologyClass: Populated Place [https://www.simphony-osp.eu/city#PopulatedPlace>,](https://www.simphony-osp.eu/city#PopulatedPlace%3E,)
           <OntologyClass: [http://www.w3.org/2002/07/owl#Thing>})](http://www.w3.org/2002/07/owl#Thing%3E}))

probably we need to add a way to traverse iteratively from one level to the other, as in the original pretty_print function.

just to add:

- Ontology individual:
  identifier: e4afaa4e-4600-4236-9627-61dd1275eb0b
  type: City (city)
  superclasses: City (city), Geographical Place (city), Populated Place (city), None (owl)
  values: coordinates: [0 0]

pretty print also gets it wrong, it should be as below:

image

This seems due to the use of frozenset which does not attempt to preserve the order (and in fact seems to order the elements alphanumerically...). Will try to use instead list(dict.fromkeys([...]))!.

as in:

for i in (list(dict.fromkeys([1, 3, 2, 2, 3, 4, 4, 5, 5]))):
    print(i)
1
3
2
4
5
@adhamhashibon adhamhashibon self-assigned this Jul 18, 2023
@adhamhashibon adhamhashibon added the bug Something isn't working label Jul 18, 2023
@adhamhashibon
Copy link
Contributor Author

fixed in #20

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

1 participant