CodeFerret icon

find duplicate blank nodes

CodeFerret | PRO | 02/08/18 03:29:30 PM UTC | 0 ⭐ | 11108 👁️ | Never ⏰ | []
SPARQL |

990 B

|

None

|

0 👍

/

0 👎

PREFIX : <http://purl.bdrc.io/ontology/core/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bdr: <http://purl.bdrc.io/resource/>
PREFIX apf: <http://jena.apache.org/ARQ/property#>
 
# find all resources with duplicate blank nodes
SELECT ?r ?diff
WHERE {
  {
    ?r a :Person .
    GRAPH ?r {
      SELECT (COUNT(?id) AS ?c) (COUNT(DISTINCT ?id) AS ?cd)
      WHERE {
        ?r :personName ?b .
        ?b rdfs:label ?nm .
        ?b a ?type .
        BIND (LANG(?nm) AS ?LANG)
        ?id apf:CONCAT (?type "+" ?nm "@" ?LANG) .
      }
     }
  } .
  BIND (?c - ?cd AS ?diff)
  FILTER (?diff != 0)
} LIMIT 10
 
 
# given a resource, ?R, report the difference of blank nodes and distinct blank nodes
SELECT ?diff
WHERE {
  { SELECT (COUNT(?id) AS ?c) (COUNT(DISTINCT ?id) AS ?cd)
    WHERE {
      ?R :personName ?b .
      ?b rdfs:label ?nm .
      ?b a ?type .
      BIND (LANG(?nm) AS ?LANG)
      ?id apf:CONCAT(?type "+" ?nm "@" ?LANG)
    }
  } .
  BIND (?c - ?cd AS ?diff)
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎