Skip to content

Load namespace prefixes into Neo4j

  • Figure out how to add namespace prefixes into Neo4j by reading them from the kg.ttl file.

From the neosemantics documentation:

"Sometimes we have an RDF header with a bunch of prefix definitions. This can come from a SPARQL query, from a Turtle document header or from an RDF/XML document root. You can grab this fragment from your RDF document and pass it to the (experimental) addNamespacePrefixesFromText method and it will try to extract the namespace definitions and add each of them individually by invoking n10s.nsprefixes.addFromText. Here’s an example of how it works:"

    WITH '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:obo="http://purl.obolibrary.org/obo/"
            xmlns:oboInOwl="http://www.geneontology.org/formats/oboInOwl#"' as txt
    CALL n10s.nsprefixes.addFromText(txt) yield prefix, namespace
    RETURN prefix, namespace;

The goal is to replace the '<rdf:RDF xmlns... ' section with a method that extracts the namespace definitions from the kg.ttl file.