Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

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


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

Using a nested query to get multiple counts

The above queries can be combined in a single query which returns multiple counts.

Code Block
titleUsing a nested query to get multiple counts
SELECT ?count_agents ?count_information_resources
WHERE {
    {
    SELECT (COUNT(DISTINCT ?s) AS ?count_agents)
    WHERE {
        ?s rdf:type foaf:Agent .
        OPTIONAL {?s rdfs:label ?label .}
        FILTER(!bound(?label))
    }
    }


    {
    SELECT (COUNT(DISTINCT ?s) AS ?count_information_resources)
    WHERE {
        ?s rdf:type vivo:InformationResource .
        OPTIONAL {?s rdfs:label ?label .}
        FILTER(!bound(?label))
    }
    }
Info
titleOld

This page contains information from older versions of VIVO

 

This query returns the number of Agents Persons; foaf:Organization without a label (#38 as of 3/7/11)

Select count(?s)

Where {

?s rdf:type foaf:Agent .

Optional {?s rdfs:label ?l} .

Filter (!bound (?l))

}

This query returns the number of UF Persons with a ufid and without a label (#0 as of 3/7/11)

Select count(?s)

Where {

?s rdf:type foaf:Person .

?s ufVivo:ufid ?u .

Optional {?s rdfs:label ?l} .

Filter (!bound (?l))

}

This query returns the number of UF Organizations with a deptID and without a label (#37 as of 3/7/11)

Select count(?s)

Where {

?s rdf:type foaf:Organization .

Optional {?s rdfs:label ?l} .

?s ufVivo:deptID ?d

Filter (!bound (?l))

}

This query returns the number of grants harvested from the DSR that do not have a label (#0 as of 3/7/11)

SELECT count(?s)

WHERE {

?s rdf:type core:Grant .

?s ufVivo:harvestedBy "DSR-Harvester" .

Optional {?s rdfs:label ?l} .

Filter (!bound (?l))

}

This query returns the number of Positions that do not have a label (#2339 as of 3/7/11)

SELECT count(?s)

WHERE {

?s rdf:type core:DependentResource .

Optional {?s rdfs:label ?l} .

Filter (!bound (?l))

}

This query returns the number of Publications that do not have a label (#0 as of 3/7/11)

SELECT count(?s)

WHERE {

?s rdf:type core:InformationResource .

Optional {?s rdfs:label ?l} .

Filter (!bound (?l))

}