Skip to content
cygri edited this page Mar 5, 2013 · 5 revisions

Welcome to the prefix.cc wiki!

Alignment with LOV

Here are a number of SPARQL query that find prefix URIs in LOV that don't have a mapping in prefix.cc. All can be run with the Jena command-line tool:

General report

This finds namespace URIs in LOV that don't exist in prefix.cc, along with their LOV prefix, and the prefix.cc URI of that prefix (if any).

PREFIX vann: <http://purl.org/vocab/vann/>
SELECT ?prefix ?lovURI ?pccURI
FROM <http://prefix.cc/popular/all.file.vann> {
 SERVICE <http://lov.okfn.org/endpoint/lov> {
   SELECT ?prefix ?lovURI {
     [] vann:preferredNamespacePrefix ?prefix;
       vann:preferredNamespaceUri ?lovURI;
   }
 }
 FILTER(NOT EXISTS { [] vann:preferredNamespaceUri ?lovURI })
 OPTIONAL {
   [] vann:preferredNamespacePrefix ?prefix;
     vann:preferredNamespaceUri ?pccURI;
 }
}
ORDER BY ?prefix

Mappings that can be safely imported into prefix.cc

Here's a version that only returns the mappings where the prefix is unassigned in prefix.cc:

PREFIX vann: <http://purl.org/vocab/vann/>
SELECT ?prefix ?URI
FROM <http://prefix.cc/popular/all.file.vann> {
  SERVICE <http://lov.okfn.org/endpoint/lov> {
    SELECT ?prefix ?URI {
      [] vann:preferredNamespacePrefix ?prefix;
        vann:preferredNamespaceUri ?URI;
    }
  }
  FILTER(NOT EXISTS { [] vann:preferredNamespaceUri ?URI })
  FILTER(NOT EXISTS { [] vann:preferredNamespacePrefix ?prefix })
}
ORDER BY ?prefix

Running:

sparql --query lov-mappings.sparql --results csv > lov-mappings.csv
php tools/csv-import.php lov-mappings.csv > lov-mappings.sql

Then import the result into the prefix.cc database using phpMyAdmin.

Clashes

Here's a version that only returns the mappings where there is a clash with prefix.cc, along with the two clashing namespace URIs from both services:

PREFIX vann: <http://purl.org/vocab/vann/>
SELECT ?prefix ?lovURI ?pccURI
FROM <http://prefix.cc/popular/all.file.vann> {
  SERVICE <http://lov.okfn.org/endpoint/lov> {
    SELECT ?prefix ?lovURI {
      [] vann:preferredNamespacePrefix ?prefix;
        vann:preferredNamespaceUri ?lovURI;
    }
  }
  FILTER(NOT EXISTS { [] vann:preferredNamespaceUri ?lovURI })
  [] vann:preferredNamespacePrefix ?prefix;
    vann:preferredNamespaceUri ?pccURI;
}
ORDER BY ?prefix

Disagreements on preferred namespace

This extracts the prefixes in LOV that use different prefixes in prefix.cc with the same URI (query provided by Ghislain Atemezing):

PREFIX vann: <http://purl.org/vocab/vann/>
SELECT ?prefix ?lovURI ?prefixcc
FROM <http://prefix.cc/popular/all.file.vann> {
  SERVICE <http://lov.okfn.org/endpoint/lov> {
    SELECT ?prefix ?lovURI {
      [] vann:preferredNamespacePrefix ?prefix;
        vann:preferredNamespaceUri ?lovURI;
    }
  }
  FILTER (?pccURI = ?lovURI && ?prefix != ?prefixcc)
  OPTIONAL {
    [] vann:preferredNamespacePrefix ?prefixcc;
      vann:preferredNamespaceUri ?pccURI;
  }
}
ORDER BY ?prefix