cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Blank nodes and names from owl Ontology

i am quite new to Neo4J and trying to import ontology via neosemantics. I had couple of questions:

  1. I tried importing first using n10s.onto.import.fetch, however seems the blank nodes are getting skipped. Are blank nodes not supported via n10s.onto.import.fetch currently?
  2. I then also tried importing the ttl file through n10s.rdf.import.fetch, however the class names from owl ontology are not getting populated in the graph. How can i have the class names populate as names of the node?
  3. On using the n10s.rdf.import.fetch, seems owl restrictions/ constructs are getting mapped to relationships in neo4j. however could some of them be mapped to properties on nodes/ edges instead?
5 REPLIES 5

Hi @caeserk , apologies but we are still finishing the updates to the documentation after the last release 😞 so there may be some bits that you will not find in the current version of the manual.
Regarding your questions:

  1. In what context are you seeing blank nodes being ignored? Restriction definitions include blank nodes but they are mapped, so you probably mean blank nodes used as subject of classes maybe?
    An RDF fragment with an example would help us understand the case you describe.
  2. The use of prefixes ns0__, ns1__ etc in the n10s.rdf.import.* procedures is documented here. I'm not entirely sure what you mean with ns0__classFieldValue, again the RDF fragment you're trying to import would be really useful.
  3. Do you refer to n10s.onto.import or n10s.rdf.import here? Could you describe how would you expect the restrictions imported instead of the way it happens now?

A useful way of testing small fragments is by using the n10s.onto.preview.* and n10s.rdf.preview.*. You can check them out here.

here's the example in the image:

call n10s.onto.preview.inline('

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix vin: <http://www.w3.org/TR/2004/REC-owl-guide-20040210/wine#> .
vin:Wine a owl:Class ;
  rdfs:subClassOf vin:PotableLiquid, [
    a owl:Restriction ;
    owl:onProperty vin:hasMaker ;
    owl:allValuesFrom vin:Winery ] .
    
','Turtle')

Please send additional details and we'll be happy to help.

Cheers,

JB.

Thank you for the reply and suggestions on using the preview/ inline mode. sorry for being unclear before. i am new to both the ontology and neo4j worlds!

To elaborate, for the example rdf snippet given above:

  1. if I run following in Neo4J browser, i do not see any references in graph to owl:Restriction on property vin:hasMaker. Is that information lost?
call n10s.onto.preview.inline('

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix vin: <http://www.w3.org/TR/2004/REC-owl-guide-20040210/wine#> .
vin:Wine a owl:Class ;
  rdfs:subClassOf vin:PotableLiquid, [
    a owl:Restriction ;
    owl:onProperty vin:hasMaker ;
    owl:allValuesFrom vin:Winery ] .
    
','Turtle')

snapshot of the graph:

  1. if instead I run the same RDF snippet with 'call n10s.rdf.preview.inline', I see references to vin:hasMaker, but the nodes in graph have no name. So visually they appear blank as seen in the image below:

Hi @caeserk , looks like you're in an older version of n10s?
Restrictions were added in the latest release ( 4.3.0.0 for Neo4j 4.3.x or 4.2.0.2 for Neo4j 4.2.7 onward). Would it be possible for you to update to any of these?
You should get something similar to what I showed on my screen capture where you can see both the SubClassOf relationship (SCO) and the Restriction with all the details (including the reference to the vin:hasMaker prop) as attributes of the relationship. I've highlighted them with the red arrow .

The reason why he went with a representation like this one is that it seems to be the one preferred by users, probably more intuitive for visualization? and is aligned with the one offered by other ontology viz libraries like WebOWL. It's actually a lot more compact than creating an intermediate node representing the restriction and linking to the node representing the vin:hasMaker prop.
But in any case and answering your question there is no information loss, all elements in the Restriction definition are stored in the graph.

With the n10s.rdf.import.* approach, you get an exact replica of the way the Restriction is defined in RDF, including the intermediate blank nodes. To make it more obvious think of the N-Triples serialization of the ontology fragment. This is what the previous ttl fragment looks as N-Triples (*):

<http://www.w3.org/TR/2004/REC-owl-guide-20040210/wine#Wine> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://www.w3.org/TR/2004/REC-owl-guide-20040210/wine#Wine> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://www.w3.org/TR/2004/REC-owl-guide-20040210/wine#PotableLiquid> .
<http://www.w3.org/TR/2004/REC-owl-guide-20040210/wine#Wine> <http://www.w3.org/2000/01/rdf-schema#subClassOf> _:genid1 .
_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:genid1 <http://www.w3.org/2002/07/owl#onProperty> <http://www.w3.org/TR/2004/REC-owl-guide-20040210/wine#hasMaker> .
_:genid1 <http://www.w3.org/2002/07/owl#allValuesFrom> <http://www.w3.org/TR/2004/REC-owl-guide-20040210/wine#Winery> .

Here you can see that there is an intermediate blank node representing the Restriction. That's what I meant, the n10s.onto.import.* produces a more "humane" view of the same information. But ultimately it's up to you which one makes more sense depending on what you're trying to achieve with the ontology.

I hope this helps.

What is the purpose of your experiment? Is it the visual exploration of the onto? Or are you planning to use it to automate some process based on it?

Cheers,

JB.

(*) You can actually try importing this version of the RDF instead, by just setting the second parameter of the preview|import procedure to "N-Triples" instead of "Turtle".

Thanks @jesus.barrasa. After upgrading to latest version, i can see the ontology imported with restrictions as you mentioned above. Are most other owl constructs supported in the latest version as well - for eg: unionOf, intersectionOf etc.?

currently I am just trying to understand the ontology and visualize how various classes in the ontology are related to each other. At the same time I am also trying to educate myself in the features of neo4j and cypher in general with respect to rdf data. thanks!

Complex classes are currently not supported but we're busy thinking what would be an efficient way of representing them. Any ideas on this are most welcome.

And in the mean time you can of course use the "selective import" via

CALL n10s.rdf.stream.fetch(...) yield subject, predicate, object, isLiteral, literalType, literalLang
WHERE predicate = ...  // select your triples here
...your custom cypher here ...   // persist them the way you want

Hope this helps.

JB.