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.

Remove prefixes from n10s nodes in browser

Hi,

when using n10s I'm using multiple prefixes.
For example:

data:ASSET__OG_O_C_CL-9_0_0_24 rdf:type owl:NamedIndividual , ont:ASSET_class ;
    ont:version "4.2" ;
    ont:description "" ;
    ont:CustomId "OG.O.C.CL-9.0.0.24" ;
    ont:Name "Sensitive Enhanced Data" ;
    ont:cluster "Policy" ;
    ont:source "Orchestra Research" ;
    neo4voc:name "Sensitive Enhanced Data"

and when I see it in the browser it looks like this:

{
  "identity": 66,
  "labels": [
    "Resource",
    "owl__NamedIndividual",
    "ns1__ASSET_class"
  ],
  "properties": {
    "ns1__source": "Orchestra Research",
    "ns0__name": "Sensitive Enhanced Data",
    "ns1__description": "",
    "ns1__cluster": "Policy",
    "ns1__CustomId": "OG.O.C.CL-9.0.0.24",
    "ns1__version": "4.2",
    "ns1__Name": "Sensitive Enhanced Data",
    "uri": "http://dev.neo4j.owl.de/data#ASSET__OG_O_C_CL-9_0_0_24"
  }
}

Question:
I there an option to present the data in the browser without all the prefixes?

Metadata:

  • Neo4j browser version: 4.0.6
  • Edition: community
  • n10s version: 4.0.0.1
1 ACCEPTED SOLUTION

What I meant is that the properties and their vaules are persisted int he neo4j graph whether you import using 'IGNORE' or any other option. Then it is up to you to choose which property is used for visualization in the browser.
The link that I sent in my previous comment shows how to control that.

JB.

View solution in original post

7 REPLIES 7

Hi Boris,
that's what I found in the documentation:

Prefixes for custom namespaces are assigned dynamically in sequence ( ns0 , ns1 , etc) as they appear in the imported RDF. This is the default behavior but we’ll see later on that it is possible to control that, and use custom prefixes. More details in section Defining custom prefixes for namespaces.

In the link provided above you will find some example on how to change the prefixes.

Hope that helps.

Best regards,
Paul

Thanks Paul, welcome to the community!
You totally hit the spot, I just went for a longer answer

Cheers,

JB.

Hi there, you have different options depending on what you want to achieve.
I'll use your example extended with some random namespaces:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix data: <http://thedata/set1#> . 
@prefix ont: <http://ontology/v1#> .
@prefix neo4voc: <http://neo4voc/v1#> .

data:ASSET__OG_O_C_CL-9_0_0_24 rdf:type owl:NamedIndividual , ont:ASSET_class ;
    ont:version "4.2" ;
    ont:description "" ;
    ont:CustomId "OG.O.C.CL-9.0.0.24" ;
    ont:Name "Sensitive Enhanced Data" ;
    ont:cluster "Policy" ;
    ont:source "Orchestra Research" ;
    neo4voc:name "Sensitive Enhanced Data" .

OPTION 1:
If you just want namespaces ignored on import, all you need to do is set the handleVocabUris property to IGNORE.

call n10s.graphconfig.init({ handleVocabUris: "IGNORE" })

Now when you import the RDF data in the usual way ( I'm using n10s.rdf.import.inline for this example), the namespaces will be stripped out and you will have more 'query-friendly' names

call n10s.rdf.import.inline('

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix data: <http://thedata/set1#> . 
@prefix ont: <http://ontology/v1#> .
@prefix neo4voc: <http://neo4voc/v1#> .

data:ASSET__OG_O_C_CL-9_0_0_24 rdf:type owl:NamedIndividual , ont:ASSET_class ;
    ont:version "4.2" ;
    ont:description "" ;
    ont:CustomId "OG.O.C.CL-9.0.0.24" ;
    ont:Name "Sensitive Enhanced Data" ;
    ont:cluster "Policy" ;
    ont:source "Orchestra Research" ;
    neo4voc:name "Sensitive Enhanced Data" .

',"Turtle")

Now when you query you get unprefixed schema elements (property names, relationship names, labels).

The problem with this approach is that you obviously will not be able to regenerate the initially imported RDF. But this may or may not be an issue for you.

OPTION 2:
If you want to export the initial RDF

Create initial config (all defaults)

call n10s.graphconfig.init()

Then (OPTIONALLY) you can add namespace prefix definitions.
For this you only need the header of your RDF doc with the namespace definitions. This is a convenience method that parses the namespace definitions from an RDF fragment (in most serialisation formats). Alternatively, you can add each namespace prefixes individually by using the n10s.nsprefixes.add method. And of course, if you skip this step, n10s will autogenerate ns0, ns1... namespaces for you.

call n10s.nsprefixes.addFromText("
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix data: <http://thedata/set1#> . 
@prefix ont: <http://ontology/v1#> .
@prefix neo4voc: <http://neo4voc/v1#> .
")

Import the RDF data with exactly the same n10s.rdf.import.inline we used in the previous example and when you run the same query,

match (r:Resource) return r

now you get a result similar to the one you showed but slightly more readable because the prefixes will be the same as in your RDF document.

Now if what you want is to get the result of your query as RDF, you can use n10s export capabilities (you can test it from the browser too). It would be something like this;

:POST http://localhost:7474/rdf/neo4j/cypher
{"cypher": "match (r:Resource) return r"}

and you should get exactly the same RDF you imported

Hope this helps,

JB.

Hi, thanks for the answers.
@jesus.barrasa,

  • option-1 indeed removes the prefixes. But simultaneously it removes the visual name/label from the node. I tried using 2 syntaxes:
  1. rdfs:label "Sensitive Enhanced Data" .
    
  2. neo4voc:name "Sensitive Enhanced Data" .
    
    
  • option-2 doesn't remove the prefixes, but only let's me an option to modify the prefixes. This is not what I please to achieve.

Regarding the comment you wrote:

Does it mean I won't be able to do export of the data?

Thanks in advance,
Boris

Hi @boris.bakman,
If I understand it right, what you're asking relating to visual has to do with the styling of the browser viz.

On the other question, what I mean is that yes you will be able to serialise your neo4j graph as RDF but it will use neo4j generated namespaces instead of the ones in the original RDF data. Let me know if this is clear, otherwise, I can produce an example for you

Cheers,

JB.

Following the example in: https://neo4j.com/docs/labs/nsmntx/current/import/#actual-rdf-import
I ran 2 times:

1) With { handleVocabUris: "IGNORE" }

CALL n10s.graphconfig.init()
CALL n10s.graphconfig.set({ handleVocabUris: "IGNORE" });
call n10s.rdf.import.inline('@prefix neo4voc: <http://neo4j.org/vocab/sw#> .
@prefix neo4ind: <http://neo4j.org/ind#> .

neo4ind:nsmntx3502 neo4voc:name "NSMNTX" ;
			   a neo4voc:Neo4jPlugin ;
			   neo4voc:version "3.5.0.2" ;
			   neo4voc:releaseDate "03-06-2019" ;
			   neo4voc:runsOn neo4ind:neo4j355 .

neo4ind:apoc3502 neo4voc:name "APOC" ;
			   a neo4voc:Neo4jPlugin ;
			   neo4voc:version "3.5.0.4" ;
			   neo4voc:releaseDate "05-31-2019" ;			   
			   neo4voc:runsOn neo4ind:neo4j355 .

neo4ind:graphql3502 neo4voc:name "Neo4j-GraphQL" ;
			   a neo4voc:Neo4jPlugin ;
			   neo4voc:version "3.5.0.3" ;
			   neo4voc:releaseDate "05-05-2019" ;			   
			   neo4voc:runsOn neo4ind:neo4j355 .			   			   

neo4ind:neo4j355 neo4voc:name "neo4j" ;
			   a neo4voc:GraphPlatform , neo4voc:AwesomePlatform ;
			   neo4voc:version "3.5.5" .
',"Turtle")

Result:

2) Without { handleVocabUris: "IGNORE" }
Result

Question

  • How can I assign the labels while using the "IGNORE"?

What I meant is that the properties and their vaules are persisted int he neo4j graph whether you import using 'IGNORE' or any other option. Then it is up to you to choose which property is used for visualization in the browser.
The link that I sent in my previous comment shows how to control that.

JB.