NeoSemantics Question: Please

While graphs are schemeless, our models are not. I have been studying Neosematics to incorporate ontologies into our stream of consciousness. The presentations that Jesus Barrasa are really excellent. I am going through them now, but there is a gap in my understanding that hopefully someone can shed some light on. In one of his presentations, he shows how to convert an ontology (through SparQL and python rdflib) into cypher templates which can then be used to enforce a schema at creation time on our models. Does such a thing exist directly in neosemantics, or should we do the Ontology->Conversion mechanism directly. I want to Enforce a Schema directly in my Model. Nothing can be created unless our ontology allows it.. I don’t want to enforce the ontology over top of an existing graph.. can neosemantics help, or do this? How?.. I just need to know the best path to go down. Hopefully my questions made some kind of sense, I am new to this so… Thoughts?

Hi @rlukas,
Very good questions!
Let's start from the beginning: Ontologies are technically not constraints but rather descriptive artifacts that can help you derive new facts (data) from the ones you have explicitly stored in your database. You can find an example of what I mean by this in episode 4 of GoingMeta (Ontology based reasoning 101).
That said, it's very common to see ontologies understood as a definition of the expected schema/shape of your graph and, therefore, interpreted as constraints that we want to enforce on our data. To do this you have two options:

  • Option 1 is the one you describe: you use the ontology to dynamically create the data ingestion pipeline. If your ETL is driven by your ontology then your graph is guaranteed to align with the expected schema defined by it. This is described in episode 5 (Ontology-driven Knowledge Graph construction)
  • Option 2 is to translate your ontology into constraints in your graph database so that regardless of the ingestion path (which you may or may not have control over) will protect your graph from diverging from the expected schema. In going meta we have explored the use of another W3C standard called SHACL in episode 3 (Controlling the shape of your graph with SHACL). Here it will be your job to translate your ontology if you have one described in OWL or RDFS into an "equivalent" SHACL description. You will see that practitioners are often skipping the OWL step altogether and working directly with SHACL and referring to it as an ontology. I'm ok with that too, btw. Once you have your SHACL definition you just need to load it into the DB using neosemantics as described in episode 3 and the database will take care of rejecting any write operation that would violate the definitions in your SHACL "ontology". You could think of alternative implementations of the same idea using Pydantic.

I hope this helps.

JB

1 Like

Thanks sir for your kindness in helping me out.. thanks man!
I'm on it.. !