You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Current »

Count entities without labels

These examples show how to count the entities in your VIVO that do not have labels.  In each query, the entities of interest are selected using type, then OPTIONAL is used to include entities with and without labels, FILTER is used to select only those results for which there is no label value, that is, ?label is not bound.

The resulting collection of entities is counted using COUNT(DISTINCT ?s) in the SELECT statement.

The same pattern can be used to count grants (vivo:Grant), organizations (foaf:Organization), or people (foaf:Person) with labels.

Count agents without labels
SELECT (COUNT(DISTINCT ?s) AS ?count)
WHERE {
    ?s rdf:type foaf:Agent .
    OPTIONAL {?s rdfs:label ?label .}
    FILTER(!bound(?label))
}


Count information resources without labels
SELECT (COUNT(DISTINCT ?s) AS ?count)
WHERE {
    ?s rdf:type vivo:InformationResource .
    OPTIONAL {?s rdfs:label ?label .}
    FILTER(!bound(?label))
}
  • No labels