-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
👋 Hi,
I'm starting to work with the Nomisma ontology. My primary goal is to align Celtic coins with it, collaborating with the Nomisma team and others. To better understand how it works and to be able to explain it to my team (IRAMAT-CNRS, France), I would like to visualize it as an interactive graph in Jupyter Notebook. However, I am only somewhat familiar with RDF structures, and my initial attempts have not been satisfactory. Any help will be welcome. Here is the Python code iI used (in Colab)
ontology_file = "http://nomisma.org/ontology.rdf" # Example OWL file
g = rdflib.Graph() # rdflib.Graph()
g.parse(ontology_file)
RDFS = rdflib.namespace.RDFS
nx_graph = nx.DiGraph()
for subj, pred, obj in g:
nx_graph.add_node(str(subj))
nx_graph.add_node(str(obj))
nx_graph.add_edge(str(subj), str(obj), label=str(pred))
net = Network(height="600px", width="100%", notebook=True, directed=True, cdn_resources='remote')
for node in nx_graph.nodes:
net.add_node(node, title=node, label=node.split("/")[-1].split("#")[-1]) # Shorten URI labels
for edge in nx_graph.edges:
net.add_edge(edge[0], edge[1], title=nx_graph[edge[0]][edge[1]]["label"].split("/")[-1])
net.show("nomisma_ontology.html")
display(HTML("nomisma_ontology.html"))Metadata
Metadata
Assignees
Labels
No labels