Nanopublication

< Home

ID

https://w3id.org/np/RAn6xOVHbJF96HHRnccpC5YGilfSVYtxv9zNkuoNlTuuQ

Formats

.trig | .trig.txt | .jelly | .jelly.txt | .jsonld | .jsonld.txt | .nq | .nq.txt | .xml | .xml.txt

Content

@prefix this: <https://w3id.org/np/RAn6xOVHbJF96HHRnccpC5YGilfSVYtxv9zNkuoNlTuuQ> .
@prefix sub: <https://w3id.org/np/RAn6xOVHbJF96HHRnccpC5YGilfSVYtxv9zNkuoNlTuuQ/> .
@prefix np: <http://www.nanopub.org/nschema#> .
@prefix grlc: <https://w3id.org/kpxl/grlc/> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix nt: <https://w3id.org/np/o/ntemplate/> .
@prefix npx: <http://purl.org/nanopub/x/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix orcid: <https://orcid.org/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

sub:Head {
  this: a np:Nanopublication;
    np:hasAssertion sub:assertion;
    np:hasProvenance sub:provenance;
    np:hasPublicationInfo sub:pubinfo .
}

sub:assertion {
  sub:get-thread-of-contribution a grlc:grlc-query;
    dct:description "Returns the whole discussion thread that the given contribution belongs to: its first contribution and all responses at any depth, whichever contribution of the thread is given. A contribution is a schema:Statement or schema:Question with its text in rdf:value, following the Nanoarguments model. It responds to another contribution through as:inReplyTo or a rhetorical CiTO stance (supports, disputes, qualifies, agreesWith, and so on) or na:tests, pointing at the contribution itself or at the nanopublication holding it; citation relations such as cito:citesAsEvidence do not make it a response. One row per contribution, in the columns a thread view reads (reply, relation, in_reply_to, by, date). The relation is the CiTO stance where there is one, else asks for a question, answers for a statement responding to a question, and replies otherwise. A contribution republished under the same IRI shows its latest version by its author: one signed with the key of the nanopublication that minted the IRI, where that nanopublication holds the contribution itself. A nanopublication by anyone else that keeps the IRI, such as an override, is not taken as a new version of it. Retracted and superseded nanopublications and example nanopublications are left out.";
    dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
    rdfs:label "Get the discussion thread of a contribution";
    grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
    grlc:sparql """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix prov: <http://www.w3.org/ns/prov#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix schema: <https://schema.org/>
prefix schemah: <http://schema.org/>
prefix as: <https://www.w3.org/ns/activitystreams#>
prefix cito: <http://purl.org/spar/cito/>
prefix na: <https://w3id.org/nanoarguments/>

select ?reply ?reply_label ?relation ?in_reply_to ?by ?by_label ?date ?support_stance ?dispute_stance ?np ?np_label
where {
  {
    select ?reply ?np ?a ?prov ?pi ?date
      (max(if(?ctype = schema:Question, 1, 0)) as ?isQuestion)
      (min(str(?p)) as ?parentStr)
      (min(if(?rel = as:inReplyTo, \"~\", str(?rel))) as ?stanceStr)
      (max(if(bound(?pqa), 1, 0)) as ?toQuestion)
    where {
      {
        # the latest valid, non-example version of each contribution
        select ?reply ?onp (max(?created) as ?date) where {
          {
            # the contributions of the thread that the given contribution belongs to
            select distinct ?reply where {
              {
                select distinct ?root where {
                  values ?atype { schema:Statement schema:Question }
                  graph ?aa { ?_resource_iri a ?atype ; rdf:value ?av . }
                  graph npa:graph {
                    ?anp np:hasAssertion ?aa ; npa:hasValidSignatureForPublicKeyHash ?apk .
                    filter not exists { ?ax npx:invalidates ?anp ; npa:hasValidSignatureForPublicKeyHash ?apk . }
                  }
                  ?_resource_iri (as:inReplyTo|na:tests|cito:agreesWith|cito:confirms|cito:corrects|cito:critiques|cito:derides|cito:disagreesWith|cito:discusses|cito:disputes|cito:extends|cito:parodies|cito:qualifies|cito:refutes|cito:repliesTo|cito:retracts|cito:reviews|cito:ridicules|cito:speculatesOn|cito:supports|cito:updates|npx:introduces)* ?root .
                  filter not exists {
                    values ?rrel {
                      as:inReplyTo na:tests cito:agreesWith cito:confirms cito:corrects
                      cito:critiques cito:derides cito:disagreesWith cito:discusses cito:disputes
                      cito:extends cito:parodies cito:qualifies cito:refutes cito:repliesTo
                      cito:retracts cito:reviews cito:ridicules cito:speculatesOn cito:supports
                      cito:updates
                    }
                    graph ?ra { ?root ?rrel ?rt . }
                    values ?rtt { schema:Statement schema:Question }
                    graph ?rta { ?rt a ?rtt ; rdf:value ?rtv . }
                    filter(?rt != ?root)
                  }
                }
              }
              ?reply (as:inReplyTo|na:tests|cito:agreesWith|cito:confirms|cito:corrects|cito:critiques|cito:derides|cito:disagreesWith|cito:discusses|cito:disputes|cito:extends|cito:parodies|cito:qualifies|cito:refutes|cito:repliesTo|cito:retracts|cito:reviews|cito:ridicules|cito:speculatesOn|cito:supports|cito:updates|npx:introduces)* ?root .
            }
          }
          values ?type { schema:Statement schema:Question }
          graph ?va { ?reply a ?type ; rdf:value ?vv . }
          graph npa:graph {
            ?vnp np:hasAssertion ?va ; np:hasPublicationInfo ?vpi ;
              npa:hasValidSignatureForPublicKeyHash ?vpk ; dct:created ?created .
            filter not exists { ?vx npx:invalidates ?vnp ; npa:hasValidSignatureForPublicKeyHash ?vpk . }
          }
          filter not exists { graph ?vpi { ?vnp npx:hasNanopubType npx:ExampleNanopub . } }
          # only its author's versions count: those signed with the key of the nanopublication
          # whose namespace the contribution's IRI was minted in, if that nanopublication holds
          # the contribution itself. Someone else's nanopublication keeping the IRI (an
          # override) is not a new version of it. Where the minting nanopublication does not
          # hold the contribution (an IRI taken over from a template, say), any version counts.
          bind(iri(replace(str(?reply), \"^(.*RA[A-Za-z0-9_-]{43}).*$\", \"$1\")) as ?onp)
          filter not exists {
            graph npa:graph { ?onp np:hasAssertion ?oa ; npa:hasValidSignatureForPublicKeyHash ?opk . }
            filter(?opk != ?vpk)
            graph ?oa { ?reply a ?otype ; rdf:value ?ov . }
            filter(?otype in (schema:Statement, schema:Question))
          }
        } group by ?reply ?onp
      }
      graph npa:graph {
        ?np dct:created ?date ; np:hasAssertion ?a ; np:hasProvenance ?prov ; np:hasPublicationInfo ?pi ;
          npa:hasValidSignatureForPublicKeyHash ?npk .
      }
      values ?ctype { schema:Statement schema:Question }
      graph ?a { ?reply a ?ctype ; rdf:value ?cv . }
      # the same rule for the version of that date, which someone else's could share
      filter not exists {
        graph npa:graph { ?onp np:hasAssertion ?oa ; npa:hasValidSignatureForPublicKeyHash ?opk . }
        filter(?opk != ?npk)
        graph ?oa { ?reply a ?otype ; rdf:value ?ov . }
        filter(?otype in (schema:Statement, schema:Question))
      }
      # what it responds to: a reply or a CiTO stance toward another contribution
      # (directly, or via the nanopublication that holds it)
      optional {
        values ?rel {
          as:inReplyTo na:tests cito:agreesWith cito:confirms cito:corrects cito:critiques
          cito:derides cito:disagreesWith cito:discusses cito:disputes cito:extends cito:parodies
          cito:qualifies cito:refutes cito:repliesTo cito:retracts cito:reviews cito:ridicules
          cito:speculatesOn cito:supports cito:updates
        }
        graph ?a { ?reply ?rel ?t . }
        optional {
          graph npa:graph { ?t np:hasAssertion ?ta . }
          graph ?ta { ?tn a ?tnt . }
          filter(?tnt in (schema:Statement, schema:Question))
        }
        bind(coalesce(?tn, ?t) as ?p)
        filter(?p != ?reply)
        filter exists {
          values ?ptype { schema:Statement schema:Question }
          graph ?pa { ?p a ?ptype ; rdf:value ?pv . }
          graph npa:graph {
            ?pnp np:hasAssertion ?pa ; npa:hasValidSignatureForPublicKeyHash ?ppk .
            filter not exists { ?px npx:invalidates ?pnp ; npa:hasValidSignatureForPublicKeyHash ?ppk . }
          }
        }
        optional { graph ?pqa { ?p a schema:Question . } }
      }
    } group by ?reply ?np ?a ?prov ?pi ?date
  }
  bind(iri(?parentStr) as ?in_reply_to)
  bind(if(coalesce(?stanceStr, \"~\") != \"~\", ?stanceStr,
         if(?isQuestion = 1, \"asks\",
           if(!bound(?in_reply_to), \"\",
             if(?toQuestion = 1, \"answers\", \"replies\")))) as ?relation)
  optional { graph ?a { ?reply rdf:value ?reply_label . } }
  optional { graph ?prov { ?a prov:wasAttributedTo ?attr . } }
  optional { graph ?pi { ?np dct:creator ?creator . } }
  bind(coalesce(?attr, ?creator) as ?by)
  optional { graph ?pi { ?by foaf:name ?by_label . } }
  bind(cito:supports as ?support_stance)
  bind(cito:disputes as ?dispute_stance)
  bind(\"^\" as ?np_label)
}
order by ?date
""" .
}

sub:provenance {
  sub:assertion prov:wasAttributedTo orcid:0000-0002-1267-0234 .
}

sub:pubinfo {
  orcid:0000-0002-1267-0234 foaf:name "Tobias Kuhn" .
  
  this: dct:created "2026-11-23T14:14:46.022+01:00"^^xsd:dateTime;
    dct:creator orcid:0000-0002-1267-0234;
    dct:license <https://creativecommons.org/licenses/by/4.0/>;
    npx:embeds sub:get-thread-of-contribution;
    npx:supersedes <https://w3id.org/np/RAFwMxXlqnv0enr10THFc5O399xjQuH9BEJzaCQo9susQ>;
    rdfs:label "Get the discussion thread of a contribution";
    nt:wasCreatedFromProvenanceTemplate <https://w3id.org/np/RA7lSq6MuK_TIC6JMSHvLtee3lpLoZDOqLJCLXevnrPoU>;
    nt:wasCreatedFromPubinfoTemplate <https://w3id.org/np/RACJ58Gvyn91LqCKIO9zu1eijDQIeEff28iyDrJgjSJF8>,
      <https://w3id.org/np/RAoTD7udB2KtUuOuAe74tJi1t3VzK0DyWS7rYVAq1GRvw>, <https://w3id.org/np/RAukAcWHRDlkqxk7H2XNSegc1WnHI569INvNr-xdptDGI>;
    nt:wasCreatedFromTemplate <https://w3id.org/np/RAEFAt-QcFK0ZhqfvlsmS10BnzGJA0xwOICZXkO-ai87k> .
  
  sub:sig npx:hasAlgorithm "RSA";
    npx:hasPublicKey "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwUtewGCpT5vIfXYE1bmf/Uqu1ojqnWdYxv+ySO80ul8Gu7m8KoyPAwuvaPj0lvPtHrg000qMmkxzKhYknEjq8v7EerxZNYp5B3/3+5ZpuWOYAs78UnQVjbHSmDdmryr4D4VvvNIiUmd0yxci47dTFUj4DvfHnGd6hVe5+goqdcwIDAQAB";
    npx:hasSignature "eMY8uSeIKURhD/fCmhVe/IV5cyf5pczIjr/mOcPADKBslPOWscbVevVFd8CImoXOiTlqy3Ac/EDZ/ivfID5fytth+OTto1F/7R8DNpnW68m1GcQ0RN8tWSkN6YeJ4jDESEO7/uveKSupEnlke13ZYaGxJIhvuz6NYMwANX8chvY=";
    npx:hasSignatureTarget this:;
    npx:signedBy orcid:0000-0002-1267-0234 .
}