Created
January 11, 2022 22:54
-
-
Save dridk/b20a09a67510377c5400cb35297adf30 to your computer and use it in GitHub Desktop.
OWL to oracle thesaurus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nxontology.imports import from_file | |
import networkx as nx | |
g = from_file("hp.owl") | |
space = 0 | |
previous_first ="" | |
previous_second ="" | |
tab = " " | |
for i, node in enumerate(nx.dfs_labeled_edges(g.graph)): | |
first, second, sens = node | |
if "HP" in first: | |
if sens =="forward": | |
label = g.node_info(second).label | |
margin = "" | |
if space > 0: | |
margin = tab * space + " NT " | |
print(f"{margin}{label}") | |
if sens == "forward": | |
space +=1 | |
if sens == "reverse": | |
space -= 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code convert an OWL ontology to a nested text suitable for ORACLE thesaurus .
Output examples :