amine4392
amine4392

Reputation: 99

counting the number of rdfs:label properties with NON-NULL values from DBpedia

I need to count the number of rdfs:label properties with NON-NULL values from DBpedia.

I already have the total number of rdfs:label properties (NULL and NON-NULL values) from DBpedia using this query:

select (COUNT(*) as ?labelNum)
  WHERE { ?s rdfs:label ?o
}

I tried this query to get the rdfs:label with NULL values, but it returns 0:

SELECT (COUNT(*) as ?nullLabelNum)
  WHERE { ?s rdfs:label ?o
filter(isBlank(?o)) }

Upvotes: 1

Views: 48

Answers (1)

If an entity doesn’t have a value for rdfs:label, this entity can’t even have the rdfs:label property.

So your first query already counts how many rdfs:label values exist in the graph.


The isBlank from your second query checks if the value is a blank node, which is something that ideally doesn’t happen, because rdfs:label has rdfs:Literal as range (and blank nodes aren’t literals).

To only count rdfs:label values that are literals (which should be the case for all of them, barring errors), you can use isLiteral:

FILTER isLiteral(?o)

To exclude certain values from your count, e.g. the empty string, you could use

FILTER(?o != "")

Upvotes: 0

Related Questions