Spellchecking vocabularies with SPARQL

Dan Brickley experiments with using SPARQL queries to check on the vocabularies used in an RDF file.

Here’s a query that checks my FOAF file for properties that are in the FOAF namespace, but not declared in the FOAF RDFS file.

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
FROM <http://richard.cyganiak.de/foaf.rdf>
    ?s ?property ?o
    GRAPH foaf: {
        OPTIONAL {
            ?property a ?t
            FILTER (?t = owl:ObjectProperty || ?t = owl:DatatypeProperty
                || ?t = rdf:Property || ?t = owl:FunctionalProperty
                || ?t = owl:InverseFunctionalProperty)
    FILTER (!BOUND(?t))
    FILTER (REGEX(STR(?property), "^http://xmlns\\.com/foaf/0\\.1/"))

This query actually finds some stuff — here are the results as of today:

| property              |
| foaf:withOrganization |
| foaf:hpmepage         |
| foaf:linkedWith       |

One’s a typo, and I’ve no idea how I got the idea that the other two were in FOAF.

SPARQL: SPellchecker And RDF Query Language!

This entry was posted in General, Semantic Web. Bookmark the permalink.