Advertisement
CodeFerret

find duplicate blank nodes

Feb 8th, 2018
2,603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SPARQL 0.99 KB | None | 0 0
  1. PREFIX : <http://purl.bdrc.io/ontology/core/>
  2. PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  3. PREFIX bdr: <http://purl.bdrc.io/resource/>
  4. PREFIX apf: <http://jena.apache.org/ARQ/property#>
  5.  
  6. # find all resources with duplicate blank nodes
  7. SELECT ?r ?diff
  8. WHERE {
  9.   {
  10.     ?r a :Person .
  11.     GRAPH ?r {
  12.       SELECT (COUNT(?id) AS ?c) (COUNT(DISTINCT ?id) AS ?cd)
  13.       WHERE {
  14.         ?r :personName ?b .
  15.         ?b rdfs:label ?nm .
  16.         ?b a ?type .
  17.         BIND (LANG(?nm) AS ?LANG)
  18.         ?id apf:CONCAT (?type "+" ?nm "@" ?LANG) .
  19.       }
  20.      }
  21.   } .
  22.   BIND (?c - ?cd AS ?diff)
  23.   FILTER (?diff != 0)
  24. } LIMIT 10
  25.  
  26.  
  27. # given a resource, ?R, report the difference of blank nodes and distinct blank nodes
  28. SELECT ?diff
  29. WHERE {
  30.   { SELECT (COUNT(?id) AS ?c) (COUNT(DISTINCT ?id) AS ?cd)
  31.     WHERE {
  32.       ?R :personName ?b .
  33.       ?b rdfs:label ?nm .
  34.       ?b a ?type .
  35.       BIND (LANG(?nm) AS ?LANG)
  36.       ?id apf:CONCAT(?type "+" ?nm "@" ?LANG)
  37.     }
  38.   } .
  39.   BIND (?c - ?cd AS ?diff)
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement