Re: Lists of tagged strings in RDF

Dear William,

Thanks. I was aware of N3, but not so much of its reasoning capabilities. I
tend to err towards RDF4J like systems, SPARQL, would really like to use
RDF-star (the data I'm working with has property-graph elements). So I have
to ponder on how N3 would fit in ... But definitely something to dig into.

Best regards,
Frens Jan

On Thu, Jun 10, 2021 at 7:06 PM William Van Woensel <
William.Van.Woensel@dal.ca> wrote:

> Hi Jan
>
>
>
> Notation3, being an extension of Turtle, supports lists as * first-class
> citizens*. This goes beyond syntactic sugar – reasoners invariably
> implement them as separate data types, and N3 includes various builtins
> <https://w3c.github.io/N3/ns/list.html> to operate on lists within rules.
> (Note that N3 lists are still equivalent to RDF lists
> <https://www.w3.org/TeamSubmission/n3/#lists> if you include some extra
> axioms.)
>
>
>
> For instance:
>
>
>
> :frens :name ( [ :givenName "Frens" ]
>
>                [ :givenName "Jan" ]
>
>                [ :familyName "de Vries" ] ) .
>
>
>
> # print your family name
>
> { ?person :name ?l . ?l list:member [ :familyName ?familyName ] } =>
>
>                 { ?person :familyName ?familyName } .
>
>
>
> Or, if you want to re-construct your full name as a string:
>
>
>
> { ?person :name ?l .
>
>     (?str
>
>      {
>
>                ?l list:member ?member .
>
>                ?member ?predicate ?name .
>
>                (?name " ") string:concatenation ?str
>
>      }
>
>     ?strs) log:collectAllIn _:x .
>
>     ?strs string:concatenation ?fullName
>
>
>
> } => { ?person :fullName ?fullName } .
>
>
>
> You can try out these examples here:
> http://ppr.cs.dal.ca:3002/n3/editor/s/aere5ifV
>
>
>
>
>
> Regards,
>
>
>
> William
>
>
>
> *From:* Rumph, Frens Jan <mail@frensjan.nl>
> *Sent:* Thursday, June 10, 2021 11:50 AM
> *To:* Martynas Jusevičius <martynas@atomgraph.com>
> *Cc:* semantic-web@w3.org
> *Subject:* Re: Lists of tagged strings in RDF
>
>
>
> *CAUTION:* The Sender of this email is not from within Dalhousie.
>
> The syntactic sugar list in turtle and sparql is pretty nice. It's the
> fact that the RDF abstract model has no real support for lists. Querying is
> a pain if you ask me. The context I'm in doesn't involve a lot of manual
> writing of RDF data.
>
> I was hoping to find a way that hurts my brain a little less. And I would
> really like to find a way to ensure that datasets won't contain malformed
> lists like:
>
>
>
> :frens :name _:n1 .
>
> _:n1 rdf:first "Frens" .
>
> _:n1 rdf:first "Jan" .
>
> _:n1 rdf:rest "de Vries" .
>
> The systems I'm targeting won't typically consume manually generated RDF,
> but there are API's for external users in play ... Perhaps I'll give
> SHACL a go with dash#ListShape <http://datashapes.org/dash#ListShape>.
>
>
>
>
>
> On Thu, Jun 10, 2021 at 12:20 PM Martynas Jusevičius <
> martynas@atomgraph.com> wrote:
>
> Why is the list syntax ( ) not satisfactofy?
>
>
>
> On Thu, 10 Jun 2021 at 12.07, Rumph, Frens Jan <mail@frensjan.nl> wrote:
>
> Dear readers,
>
>
>
> I am investigating transitioning an application to use RDF. One roadblock
> is how this application models names of persons. It supports
> straight-forward full names as a single string, but also supports
> decomposed names, e.g. person X has given name *Frens* followed by a second
> given name *Jan* followed by the family name *Rumph*.
>
>
>
> Note that this is a crosspost of
> https://stackoverflow.com/questions/65982459/rdf-modelling-of-list-of-name-elements
> <https://stackoverflow..com/questions/65982459/rdf-modelling-of-list-of-name-elements>.
> I hope to get some more
>
>
>
> The data structure is something like:
>
>
>
> ```java
>
> enum Role {
>
>    ...
>
>    GIVEN_NAME,
>
>    FAMILY_NAME,
>
>    ...
>
> }
>
>
>
> record NameElement(role: Role, value: String) {}
>
>
>
> record AnnotatedName(NameElement... elements) {}
>
> ```
>
>
>
> in order to be instantiated like:
>
>
>
> ```java
>
> var name = new AnnotatedName(
>
>     new NameElement(GIVEN_NAME, "Frens"),
>
>     new NameElement(GIVEN_NAME, "Jan"),
>
>     new NameElement(FAMILY_NAME, "de Vries")
>
> );
>
> ```
>
>
>
> This allows reconstruction of the name into a string while at the same
> time expressing the components of the name. So it captures the roles of the
> elements of a name (e.g. given names, family names) *as well as* their
> order (given names aren't first everywhere). Also, it allows expressing
> multiple names. E.g. in multiple languages / scripts. Or even aliases used
> in different areas of the world.
>
>
>
> I have toyed around with some RDF constructs, but none are really
> satisfactory:
>
>
>
> ```turtle
>
> # list of strings misusing data types as tags
>
> :frens :name ( "Frens"^^:givenName "Jan"^^:givenName "de
> Vries"^^:familyName ) .
>
>
>
> # list of blank nodes
>
> :frens :name ( [ :givenName "Frens" ]
>
>                [ :givenName "Jan" ]
>
>                [ :familyName "de Vries" ] ) .
>
>
>
> # single blank node with unordered 'elements'
>
> :frens :name [ a           :AnnotatedPersonName ;
>
>                :fullName   "Frens Jan de Vries" ;
>
>                :givenName  "Frens" ;
>
>                :givenName  "Jan" ;
>
>                :familyName "de Vries" ] .
>
> ```
>
>
>
> ---
>
>
>
> **Existing ontologies for HD names?**
>
> Is there an existing ontology that covers such 'high fidelity'? FOAF and
> vcard have some relevant properties, but aren't able to capture this level
> of semantics.
>
>
>
> **Lists?** One major 'blocker' in migrating this approach to RDF is the
> notion of order that is used. If at all possible, I'd like to stay away
> from the List / Container swamp in RDF land ...
>
>
>
> I'd be grateful for any thoughts on the matter!
>
>
>
> Best regards,
>
> Frens Jan
>
>

Received on Thursday, 10 June 2021 19:11:37 UTC