Neosemantics generate RDF multilanguage Elements

Hi There, I tried to export an RDF XML using neosemantics plugin and the following mapping

CALL n10s.mapping.add("http://www.w3.org/2004/02/skos/core#prefLabel", "prefLabel:en");
CALL n10s.mapping.add("http://www.w3.org/2004/02/skos/core#prefLabel", "prefLabel:de");

The result should be an XML like:

<skos:prefLabel lang=“de“>Schwarzweiß</skos:prefLabel>
<skos:prefLabel lang=“en“>BlackWhite</skos:prefLabel>

How can I define mapping for node properties like this?

prefLabel.de:""
prefLabel.en:""

Many thanks in advance

Konrad

Hi @konrad.eichstaedt welcome to the community,

There is a section in the manual on dealing with language tags.
You don't need a mapping but rather a configuration option. You need to set that up on import.
Once the data has been imported preserving the language tags, it will be automatically added on export.

Hope this helps.

JB.

1 Like

Hi @jesus_barrasa many thanks for your support. But as soon as I activate the graph config the rdf export as result from this PATH /rdf/neo4j/describe/149447?format=RDF/XML&excludeContext=true

is empty

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
	xmlns:schema="https://schema.org/"
	xmlns:gndo="https://d-nb.info/standards/elementset/gnd#"
	xmlns:skos="http://www.w3.org/2004/02/skos/core#"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

</rdf:RDF>

Have you any idea because of why?

Again from the manual :wink:
When exporting a graph that's the result of importing RDF you should use the uri of the resource you want to export, not the internal id.

JB.

BTW, I'm assuming that your graph is the result of importing RDF data via neosemantics(n10s).
Am I correct?

JB.

Hi @jesus_barrasa no the nodes and relationships in neo4j are created using a java application and neo4j ORM mapper. Is this a problem?

Hi @jesus_barrasa the export documentation says:

The only required parameter is node’s unique identifier: If the graph is the result of importing RDF using n10s it will be the uri and if the graph is not the result of importing RDF, then we’ll use the node ID. Whether we’re in one case or the other will be determied by the presence of a Graph Configuration (see Config Neo4j to use RDF Data)

that isn't possible to export a graph which wasn't imported from RDF. But as soon as I active the GraphConfig the RDF Export is empty, do you give me a hint what Iam doing wrong?

Many Thanks

Konrad

Hi, it's not a problem, I just assumed it was the case so my suggestion of creating a graph config is not useful in this case.
In your case all you need to do is annotate your property values with the language tag as follows:

CREATE (n:Thing {
  uri: "http://mynamespace.com/1234", 
  otherProp : 19,
  prefLabel: "Schwarzweiß@de"
});
CREATE (n:Thing {
  uri: "http://mynamespace.com/1235", 
  otherProp : 84,
  prefLabel: "BlackWhite@en"
});

note the @lang-tag added to the string value.

Then when you export it as RDF using the describe method you should get the expected result:

:get /rdf/neo4j/describe/175


@prefix n4sch: <neo4j://graph.schema#> .
@prefix n4ind: <neo4j://graph.individuals#> .

<http://mynamespace.com/1235> a n4sch:Thing;
  n4sch:otherProp "84"^^<http://www.w3.org/2001/XMLSchema#long>;
  n4sch:prefLabel "BlackWhite"@en .

similar when you export using the cypher method:

:post /rdf/neo4j/cypher
{ "cypher":"match (t:Thing) return t", "format": "RDF/XML"}

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
	xmlns:n4sch="neo4j://graph.schema#"
	xmlns:n4ind="neo4j://graph.individuals#"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

<rdf:Description rdf:about="http://mynamespace.com/1234">
	<n4sch:otherProp rdf:datatype="http://www.w3.org/2001/XMLSchema#long">19</n4sch:otherProp>
	<n4sch:prefLabel xml:lang="de">Schwarzweiß</n4sch:prefLabel>
	<rdf:type rdf:resource="neo4j://graph.schema#Thing"/>
</rdf:Description>

<rdf:Description rdf:about="http://mynamespace.com/1235">
	<n4sch:otherProp rdf:datatype="http://www.w3.org/2001/XMLSchema#long">84</n4sch:otherProp>
	<n4sch:prefLabel xml:lang="en">BlackWhite</n4sch:prefLabel>
	<rdf:type rdf:resource="neo4j://graph.schema#Thing"/>
</rdf:Description>

</rdf:RDF>

note how you can use the format parameter to select the preferred serialization format.

Hope this helps, and sorry for the initial confusion.

JB.

1 Like

Hi @jesus_barrasa Many Thanks for your support , with new structure of the label property I got the proper result:

<rdf:Description rdf:about="http://normdaten.staatsbibliothek-berlin.de/vocabulary/bw">
	<n4sch:typeName>Concept</n4sch:typeName>
	<skos:prefLabel xml:lang="de">Schwarzweiß</skos:prefLabel>
	<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
	<schema:identifier>NORM-823355b6-3ab3-3f0a-8e4d-1367e89abd1c</schema:identifier>
	<skos:notation>bw</skos:notation>
	<skos:prefLabel xml:lang="en">Black-and-white</skos:prefLabel>
	<skos:definition xml:lang="de">Digitalisierung in Schwarzweiß.</skos:definition>
</rdf:Description>

Thanks again from our team , so we can start building a knowledge graph for medieval manuscripts

1 Like

Glad that helped :)
I'd love to hear more about your project (and of course your experience with n10s), please share here!

JB.

1 Like