nvkp / turtle

Golang package for parsing and serializing the Turtle format used for representing RDF data
MIT License
3 stars 0 forks source link

Support of language tags #19

Closed jonnyschaefer closed 1 day ago

jonnyschaefer commented 1 week ago

While looking at the example from #18 I was wondering on how to differentiate all those lables. Thus it might be a good idea to support the language tags of literals sometime in the future.

Example from https://www.w3.org/TR/turtle/#turtle-literals

show:218 show:localName "That Seventies Show"@en .                 # literal with a language tag
show:218 show:localName 'Cette Série des Années Soixante-dix'@fr . # literal delimited by single quote
show:218 show:localName "Cette Série des Années Septante"@fr-be .  # literal with a region subtag

Maybe it makes sense to introduce an optional tag for a field of the triple struct, which then is filled with the language tag? Maybe capture the datatype aswell?

If I understand https://www.w3.org/TR/turtle/#grammar-production-RDFLiteral correctly, datatype and language tag can not exist simultaneously.

I have not checked how other libraries handle this.

nvkp commented 1 week ago

That's a very good idea! I am going to implement it so that two optional tags label and datatype in the struct are filled. Other libraries probably implement it by filling another field in their own struct representing either a triple or an literal. Indeed, there can be only either label or data type specified for the literal at a time:

If there is no language tag, there may be a datatype IRI, preceeded by '^^' (U+005E U+005E).

nvkp commented 1 day ago

@jonnyschaefer check out the new version v1.2.0 where I added the support for label and data type tags for both parsing and serializing.