Taxonomy XML - Using with RDF in Taxonomy import/export via XML 7
Same filename and directory in other branches
Resource Description Framework : RDF (and the Drupal RDF module) allows
us to make arbitrary statements of fact about Drupal
resources.
In this case, we need to be able to say that a given
taxonomy term is equivalent to (sameAs) a term defined in a
public dataset. Here's how we can set this up.
Install and setup
- First, download install and enable the RDF.module. This provides the API and storage of such data.
- Also install the EVOC.module and its required dependency, SPAQRL.module. This makes importing statements from outside sources easier.
-
Next, import the OWL ontology using EVOC. At evoc/import (there should be a new
menu item called "Import external RDF
vocabulary"), enter the URI for the OWL vocabulary
"
http://www.w3.org/2002/07/owl#
" and give it the prefix "owl
"
Be sure to include the trailing "#"!
If successful you will see the messageowl:sameAs successfully imported
... (amongst a lot of others)
Now we know how to say what we need to say. This new predicate (property) is available to use in statements.
Soon, we will be able to tell the system things like :
Our taxonomy term Paris
represents the same
concept as the one used by Freebase or Wordnet to represent
the locality of Paris, France, and not the one in Texas or
the one in rehab.
This will take the form of RDF statements like:
<http://example.com/taxonomy/term/4045> <http://www.w3.org/2002/07/owl#sameAs> <http://rdf.freebase.com/ns/en.paris> . <http://example.com/taxonomy/term/4045> <http://www.w3.org/2002/07/owl#sameAs> <http://id.loc.gov/authorities/sh2008116535> . <http://example.com/taxonomy/term/4045> <http://www.w3.org/2002/07/owl#sameAs> <http://dbpedia.org/resource/Paris> . <http://example.com/taxonomy/term/4045> <http://www.w3.org/2002/07/owl#sameAs> <http://d.opencalais.com/er/geo/city/ralg-geo1/797c999a-d455-520d-e5cf-04ca7fb255c1> . <http://example.com/taxonomy/term/4045> <http://www.w3.org/2002/07/owl#sameAs> <http://en.wikipedia.org/wiki/Paris> .in nice RDF/XML:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:owl="http://www.w3.org/2002/07/owl#" > <rdf:Description rdf:about="http://example.com/taxonomy/term/4045"> <owl:sameAs rdf:resource="http://rdf.freebase.com/ns/en.paris" /> <owl:sameAs rdf:resource="http://id.loc.gov/authorities/sh2008116535" /> <owl:sameAs rdf:resource="http://dbpedia.org/resource/Paris" /> <owl:sameAs rdf:resource="http://en.wikipedia.org/wiki/Paris" /> <owl:sameAs rdf:resource="http://d.opencalais.com/er/geo/city/ralg-geo1/797c999a-d455-520d-e5cf-04ca7fb255c1" /> </rdf:Description> </rdf:RDF>Or, in Turtle:
@prefix owl: <http://www.w3.org/2002/07/owl#> . <http://example.com/taxonomy/term/4045> owl:sameAs <http://rdf.freebase.com/ns/en.paris> , <http://id.loc.gov/authorities/sh2008116535> , <http://dbpedia.org/resource/Paris> , <http://en.wikipedia.org/wiki/Paris> , <http://d.opencalais.com/er/geo/city/ralg-geo1/797c999a-d455-520d-e5cf-04ca7fb255c1> .... You don't need all these! Only one will do, but I'm listing a handful for comparison to illustrate the variety.
What a mess?
Looks like a load of pointless code, but the point is that
NOW we can talk with those other data sources and they will
tell us the synonyms, translations, descriptions of that item
and its relation with other things - like a list of
districts within or the province it's inside. Great for
building up real taxonomies that are accurate,
official, and edited without typing.
Once imported, you are free to re-edit or delete
any of those values to suit yourself.
By using URIs as Globally Unique IDentifiers, those lookup services are also telling us where we can go to find more. And more.
And this is all done for you, now that the API code is in place. The RDF module will make a note of this data in your Repository, and look it up again next time it needs to know anything. Those long URLs are totally hidden from view unless you want to expose them.
Done.
The install steps have enabled this feature in the background. You won't see much on the surface, but the next vocab you import will be sitting on a framework of semantic data. This data can be inspected directly from the RDF data UI.
File
help/rdf.htmlView source
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Taxonomy XML - Using with RDF </title> <link rel="stylesheet" type="text/css" href="docs.css" /> </head> <body> <h1> Using Taxonomy XML with RDF </h1> <p> Resource Description Framework : RDF (and the Drupal <a href="http://drupal.org/project/rdf">RDF module</a>) allows us to make arbitrary statements of fact about Drupal resources. <br /> In this case, we need to be able to say that <b>a given taxonomy term is equivalent to (sameAs) a term defined in a public dataset</b>. Here's how we can set this up. </p> <h2> Install and setup </h2> <ul> <li> First, download install and enable the <a href="http://drupal.org/project/rdf">RDF.module</a>. This provides the API and storage of such data. </li> <li> Also install the <a href="http://drupal.org/project/evoc">EVOC.module</a> and its required dependency, <a href="http://drupal.org/project/sparql">SPAQRL.module</a>. This makes importing statements from outside sources easier. </li> <li> Next, import the OWL ontology using EVOC. At <a href="/evoc/import">evoc/import</a> (there should be a new menu item called "<em>Import external RDF vocabulary</em>"), enter the URI for the OWL vocabulary "<code>http://www.w3.org/2002/07/owl#</code>" and give it the prefix "<code>owl</code>" <br /> <small>Be sure to include the trailing "#"!</small> <br /> If successful you will see the message <pre>owl:sameAs successfully imported</pre> <br /> ... (amongst a lot of others) <br /> Now we know <em>how</em> to say what we need to say. This new <em>predicate</em> (property) is available to use in statements. </li> </ul> <p> Soon, we will be able to tell the system things like : </p> <blockquote> Our taxonomy term <code>Paris</code> represents the same concept as the one used by Freebase or Wordnet to represent the locality of Paris, France, and not the one in Texas or the one in rehab. </blockquote> This will take the form of RDF statements like: <pre> <http://example.com/taxonomy/term/4045> <http://www.w3.org/2002/07/owl#sameAs> <http://rdf.freebase.com/ns/en.paris> . <http://example.com/taxonomy/term/4045> <http://www.w3.org/2002/07/owl#sameAs> <http://id.loc.gov/authorities/sh2008116535> . <http://example.com/taxonomy/term/4045> <http://www.w3.org/2002/07/owl#sameAs> <http://dbpedia.org/resource/Paris> . <http://example.com/taxonomy/term/4045> <http://www.w3.org/2002/07/owl#sameAs> <http://d.opencalais.com/er/geo/city/ralg-geo1/797c999a-d455-520d-e5cf-04ca7fb255c1> . <http://example.com/taxonomy/term/4045> <http://www.w3.org/2002/07/owl#sameAs> <http://en.wikipedia.org/wiki/Paris> . </pre> in nice RDF/XML: <pre> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:owl="http://www.w3.org/2002/07/owl#" > <rdf:Description rdf:about="http://example.com/taxonomy/term/4045"> <owl:sameAs rdf:resource="http://rdf.freebase.com/ns/en.paris" /> <owl:sameAs rdf:resource="http://id.loc.gov/authorities/sh2008116535" /> <owl:sameAs rdf:resource="http://dbpedia.org/resource/Paris" /> <owl:sameAs rdf:resource="http://en.wikipedia.org/wiki/Paris" /> <owl:sameAs rdf:resource="http://d.opencalais.com/er/geo/city/ralg-geo1/797c999a-d455-520d-e5cf-04ca7fb255c1" /> </rdf:Description> </rdf:RDF> </pre> Or, in Turtle: <pre> @prefix owl: <http://www.w3.org/2002/07/owl#> . <http://example.com/taxonomy/term/4045> owl:sameAs <http://rdf.freebase.com/ns/en.paris> , <http://id.loc.gov/authorities/sh2008116535> , <http://dbpedia.org/resource/Paris> , <http://en.wikipedia.org/wiki/Paris> , <http://d.opencalais.com/er/geo/city/ralg-geo1/797c999a-d455-520d-e5cf-04ca7fb255c1> . </pre> ... You don't need all these! Only one will do, but I'm listing a handful for comparison to illustrate the variety. <h3> What a mess? </h3> <p> Looks like a load of pointless code, but the point is that NOW we can talk with those other data sources and they will tell us the synonyms, translations, descriptions of that item <em>and</em> its relation with other things - like a list of districts within or the province it's inside. Great for building up <em>real taxonomies</em> that are accurate, official, and edited without typing. <br/>Once imported, you are free to re-edit or delete any of those values to suit yourself. </p> <p> By using URIs as <b>G</b>lobally <b>U</b>nique <b>ID</b>entifiers, those lookup services are also telling us where we can go to find more. And more. </p> <p> <em>And</em> this is all done for you, now that the API code is in place. The RDF module will make a note of this data in your Repository, and look it up again next time it needs to know anything. Those long URLs are totally hidden from view unless you want to expose them. </p> <h3> Done. </h3> <p> The install steps have enabled this feature in the background. You won't see much on the surface, but the next vocab you import will be sitting on a framework of semantic data. This data can be inspected directly from the RDF data UI. </p> </body> </html>