neo4jcyphern-triples

Conversion of N-Triples to Cypher Text


I have a dump of N-Triples which I want to convert to Cypher Text, So that it can be loaded into Neo4j Database directly. For simple ontologies like rdf-syntax-ns#type I can convert easily using a script i.e

<http://www.foo.org/triple1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.foo.org/Human>

Can be easily converted as

CREATE (t1:Human { type : "triple1" })

and it is accurate and as I want it to be. But for complicated stuff like <http://www.w3.org/2002/07/owl#equivalentProperty> it gets damn crapped.

Thus my question is How to convert any triple using <http://www.w3.org/2002/07/owl#equivalentProperty> as the predicate to Cypher text?


Solution

  • See this related question for general issues of how to get RDF into Neo4J.

    For specifically the equivalentProperty stuff, the reason you're getting messed up here is that equivalentProperty is a "meta" statement that references the model itself; namely in this case, it's making a statement about properties rather than about data. In Neo4J, you don't have an explicit model in the database (we're hoping this may change over time, but for now that's how it is). So you can't talk about a property in general as such. Probably your best bet is to create a new kind of node that stands in for that property metadata.

    E.g. if you had RDF:

    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://my-ns.org/vocab#foobar>
    

    Then you might turn that into:

    MERGE (p1:Property { ns: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", name:"type" },
          (p2:Property { ns: "http://my-ns.org/vocab#", name: "foobar" }),
          (p1)-[:equivalentProperty]->(p2);
    

    The reason this works is because we're creating :Property nodes that make property metadata real. You don't get that by default with neo4j, whereas in RDF, by nature of the fact that those properties have their own URIs, they are "nodes" in RDF.