Skip to content

Rendering Numisma ontology as a graph #34

@zoometh

Description

@zoometh

👋 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions