Nanoarguments: Query Patterns
- License
- CC BY 4.0
Introduction
Here we list the published queries for the Nanoarguments discourse graph, implementing the Level 1 query patterns of the model. These queries are published as nanopublications. SPARQL representations are shown below with a link to the published version.
A query can be called via the Nanopub Query API like this:
https://query.knowledgepixels.com/api/<code>/<name>?<parameter>=<IRI>
The queries
Evidence for a claim
This query lists the contributions that take a stance on a claim (supporting, opposing, others). The parameter is claim.
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix cito: <http://purl.org/spar/cito/>
prefix oa: <http://www.w3.org/ns/oa#>
prefix sio: <http://semanticscience.org/resource/>
prefix na: <https://w3id.org/nanoarguments/>
prefix schema: <https://schema.org/>
select distinct ?evidence_iri ?evidence_iri_label ?stance ?stance_label ?user_iri where {
# Stance, label and group: 1 supporting, 2 opposing, 3 other.
values (?rel ?relLabel ?group) {
(cito:supports "supports" "1")
(cito:agreesWith "agrees with" "1")
(cito:extends "extends" "1")
(cito:disputes "disputes" "2")
(cito:critiques "critiques" "2")
(cito:corrects "corrects" "2")
(cito:qualifies "qualifies" "3")
(cito:discusses "discusses" "3")
(na:tests "tests" "3")
}
graph npa:graph {
?np np:hasAssertion ?a ; np:hasProvenance ?p ;
npa:hasValidSignatureForPublicKeyHash ?pubkey .
filter not exists { ?inv npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
}
graph ?a {
{ ?evidence_iri a schema:Statement } union { ?evidence_iri a sio:SIO_001394 }
{ ?evidence_iri ?rel ?_claim_iri . }
union
{ ?evidence_iri ?rel ?spec . ?spec oa:hasSource ?_claim_iri . }
optional { ?evidence_iri rdf:value ?text }
}
optional { graph ?p { ?a prov:wasAttributedTo ?user_iri } }
bind(concat(if(?group = "1", "✓ ", if(?group = "2", "✗ ", "· ")), ?relLabel) as ?stance)
bind(if(?group = "1", "#1a7f37", if(?group = "2", "#d1242f", "#57606a")) as ?stancecolour)
bind(concat("<svg width='110' height='16' viewBox='0 0 110 16'><text x='0' y='12' font-size='12' font-weight='500' fill='", ?stancecolour, "'>", ?stance, "</text></svg>") as ?stance_label)
bind(?text as ?evidence_iri_label)
}
order by ?group ?relLabel ?evidence_iri_label
Published: RAz18A-j…/get-evidence-for-claim
Thread under a contribution
This query lists the replies to a contribution, including replies, following as:inReplyTo. Reply texts are indented by nesting level. The parameter is resource.
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
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 as: <https://www.w3.org/ns/activitystreams#>
select ?level ?reply ?reply_label ?relation ?in_reply_to ?in_reply_to_label ?by ?by_label ?date ?reply_target ?np ?np_label
where {
{
select ?reply ?in_reply_to ?by ?created ?np
(count(distinct ?up) as ?level)
(min(?upcreated) as ?start)
(coalesce(min(?value), min(?label), str(?reply)) as ?text)
(coalesce(min(?ptext), str(?in_reply_to)) as ?parenttext)
(min(?cito) as ?relation)
(coalesce(min(?name), str(?by)) as ?by_label)
where {
values ?_resource_multi_iri {}
graph npa:graph {
?np np:hasAssertion ?a ; np:hasProvenance ?prov ; np:hasPublicationInfo ?pi ;
npa:hasValidSignatureForPublicKeyHash ?key ; dct:created ?created .
filter not exists { ?x npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?key }
}
graph ?a { ?reply as:inReplyTo ?target }
?reply (as:inReplyTo|np:hasAssertion|npx:introduces)+ ?_resource_multi_iri .
optional { graph npa:graph { ?target np:hasAssertion ?targetassertion } }
bind(coalesce(?targetassertion, ?target) as ?in_reply_to)
optional { graph ?a { ?reply rdf:value ?value } }
optional { graph ?a { ?reply rdfs:label ?label } }
optional {
graph ?a { ?reply ?citoprop ?target }
filter(strstarts(str(?citoprop), "http://purl.org/spar/cito/"))
bind(strafter(str(?citoprop), "cito/") as ?cito)
}
optional { graph ?prov { ?a prov:wasAttributedTo ?by } }
optional { graph ?pi { ?by foaf:name ?name } }
optional {
graph npa:graph {
?pnp np:hasAssertion ?pa ; npa:hasValidSignatureForPublicKeyHash ?pkey .
filter not exists { ?y npx:invalidates ?pnp ; npa:hasValidSignatureForPublicKeyHash ?pkey }
}
graph ?pa { ?in_reply_to ?ptextprop ?ptext }
filter(?ptextprop in (rdf:value, rdfs:label))
}
?reply (as:inReplyTo|np:hasAssertion)* ?up .
?up (as:inReplyTo|np:hasAssertion|npx:introduces)+ ?_resource_multi_iri .
graph npa:graph { ?upnp np:hasAssertion ?upa ; dct:created ?upcreated }
graph ?upa { ?up as:inReplyTo ?upparent }
}
group by ?reply ?in_reply_to ?by ?created ?np
}
bind(concat(substr("· · · · · · · ", 1, 2 * (?level - 1)), ?text) as ?reply_label)
bind(if(strlen(?parenttext) > 60, concat(substr(?parenttext, 1, 60), "..."), ?parenttext) as ?in_reply_to_label)
bind(substr(str(?created), 1, 10) as ?date)
bind(str(?reply) as ?reply_target)
bind("^" as ?np_label)
}
order by ?start ?created
Published: RAhdldev…/get-thread
Reasoning chain for a claim
This query lists the contributions that test a claim or are derived from it, also following longer chains. It uses na:tests and prov:wasDerivedFrom. The parameter is claim.
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix na: <https://w3id.org/nanoarguments/>
prefix schema: <https://schema.org/>
select distinct ?step_iri ?step_iri_label ?relation ?target_iri ?target_iri_label ?user_iri ?np ("^" as ?np_label) where {
values (?rel ?relation) {
(na:tests "tests")
(prov:wasDerivedFrom "was derived from")
}
# The claim or anything on its chain.
?target_iri (prov:wasDerivedFrom|na:tests)* ?_claim_iri .
graph npa:graph {
?np np:hasAssertion ?a ; np:hasProvenance ?p ;
npa:hasValidSignatureForPublicKeyHash ?pubkey .
filter not exists { ?inv npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
}
graph ?a {
?step_iri a schema:Statement ; ?rel ?target_iri .
optional { ?step_iri rdf:value ?step_iri_label }
}
optional { ?target_iri rdf:value ?target_iri_label }
optional { graph ?p { ?a prov:wasAttributedTo ?user_iri } }
}
order by ?target_iri_label ?relation ?step_iri_label
Published: RAEdY3FE…/get-reasoning-chain
Claim actions
This query returns the buttons shown on the page of a claim, such "Comment", "Add supporting evidence", and "Add counterevidence". Each button opens a template with the claim filled in. The parameter is claim.
prefix schema: <https://schema.org/>
select distinct ?content where {
graph ?a { ?_claim_iri a schema:Statement . }
bind(encode_for_uri(str(?_claim_iri)) as ?claim)
bind("/publish?template-version=latest&template=" as ?base)
bind("https%3A%2F%2Fw3id.org%2Fnp%2FRAFpID-NunXGUAZebXPfhD9efjvfpZqB5gDBrgP2Lp5N8%2Ftemplate" as ?tContribution)
bind("https%3A%2F%2Fw3id.org%2Fnp%2FRAdGQVeqqUoTNJe52OSMhY8EX1MkFA1LI4oQh-NAgrYV8%2Ftemplate" as ?tEvidence)
bind(concat(
"<a href='", ?base, ?tContribution, "&param_target=", ?claim,
"&param_stance=http%3A%2F%2Fpurl.org%2Fspar%2Fcito%2Fdiscusses'>Comment</a> ",
"<a href='", ?base, ?tEvidence, "&param_claim=", ?claim,
"&param_stance=http%3A%2F%2Fpurl.org%2Fspar%2Fcito%2Fsupports'>Add supporting evidence</a> ",
"<a href='", ?base, ?tEvidence, "&param_claim=", ?claim,
"&param_stance=http%3A%2F%2Fpurl.org%2Fspar%2Fcito%2Fdisputes'>Add counterevidence</a> ",
"<a href='", ?base, ?tContribution, "&param_target=", ?claim,
"'>Reply with a claim</a>"
) as ?content)
}
Published: RAAUyGrv…/get-claim-actions
Published queries
The snapshots on this page show the versions from 13 November 2026.
| Query | Parameter | IRI |
|---|---|---|
| Evidence for a claim | claim | RAz18A-jg43aKKd5KEsYfYjqwjbwEnMpO74jOsAtKBhno/get-evidence-for-claim |
| Thread under a contribution | resource | RAhdldevdeHe4nb9fM3CKA_cUnufQPq_xj4fuRyjTkq1o/get-thread |
| Reasoning chain for a claim | claim | RAEdY3FEckI128K5q45heT-s7hKf56cY9qDrg7vrtVQyc/get-reasoning-chain |
| Claim actions | claim | RAAUyGrveQskf4fnfZCH89fqsbyl8j7id6T9zaFCZUiAI/get-claim-actions |