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

return classes with proper ontological hierarchy #853

Open
adhamhashibon opened this issue Jun 28, 2023 · 2 comments
Open

return classes with proper ontological hierarchy #853

adhamhashibon opened this issue Jun 28, 2023 · 2 comments
Assignees
Labels
🐛 bug ❔ question ❓ information needed The issue cannot be solved until one of the interested parties provides more information. 📜 ontology

Comments

@adhamhashibon
Copy link

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.

@adhamhashibon adhamhashibon self-assigned this Jun 28, 2023
@adhamhashibon
Copy link
Author

adhamhashibon commented Jun 28, 2023

@yoavnash @kysrpex could you please review this and let me know whether it came up before?

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

@adhamhashibon
Copy link
Author

adhamhashibon commented Jun 28, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug ❔ question ❓ information needed The issue cannot be solved until one of the interested parties provides more information. 📜 ontology
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant