Enabling the Semantic Web and RDF in Plone
| Presenter: | Calvin Hendryx-Parker, Six Feet Up, Inc. |
| Date: |
Friday, October 27, 2006 |
Semantic Web Concepts
- XML
Syntax for Structured Documents
- XML Schema
Language for restricting the structure
- RDF
Data model for referring to object and their relationships
- RDF Schema
Vocabulary for describing properties
- OWL
Extended vocabulary for describing things like cardinality, equality and rich typing
What is RDF
- Resource Description Framework
- Major Component of the Semantic Web
- Neutral Format
- Directed Graph of Resources
RDF Schemas and Web Ontology Language (OWL)
- Provides Vocabulary
- Extended Object Class Vocabularies
Example Applications RDF
- FOAF
- RSS Newsfeeds
- Creative Commons
- MusicBrainz
Describing Beer
Where you can get Beer
Someone I know
Who you drink with
Describes Resources and Structures
N-Triples in Action
<http://rosettaproject.org/archive/ZZZ>
lingual:isOfLanguiodType
lingual:Language .
<http://rosettaproject.org/archive/ZZZ>
dc:title
"Dimli" .
- Triples
- Resource Identification
Real World Usage
Rosetta Project
- Project to build an archive of all documented human languages.
- Sub project of the Long Now Foundation
- 10,000 Languages
- Over 4,000 Archive Documents and growing
The Rosetta Projects Problem
- Specialized Linguistic Resources and Documents
- Content and Structure is of a Contested Nature
- Geographic Boundaries Change
- Still need Content Management
- Need extended query facilities
Many Structures One Set of Data
- Flat storage of Languages in ZODB
- Apply Many Alternate Structures via RDF
Many Structures One Set of Data
- Flat storage of Languages in ZODB
- Apply Many Alternate Structures via RDF
Many Structures One Set of Data
- Flat storage of Languages in ZODB
- Apply Many Alternate Structures via RDF
Archiving and Interoperability
- RDF/XML Serialization
- Notation3 (N3) Triples
- Expose RDF Query as a Service
Why not use Relational Databases
- Flexibility of Data Encoding and Extraction
- Graph-Based Representation
- Reification
Reification
- Talk about or Justify a Triple
- Annotation
- Supported in RDFLib via contexts
- Not used yet in Rosetta
Querying RDF
- SPARQL
- RDQL
- Implementation Specific API
- GraphPath
RDFLib
- Python Library for working with RDF
- Decoupled Storage
- SPARQL Query Implementation
def languages_by_type(self, datatype, context=documents):
sparqlGr = SPARQLGraph(self.graph)
select = ("?lang",)
where = GraphPattern([("?doc", self.rosettaType, datatype), ("?doc", self.refersToLanguoid, "?lang")])
result = sparqlGr.query(select, where)
return set(result)
- SPARQL Query Parser Coming Soon
SELECT ?lang
WHERE
{
?doc <http://rosettaproject.org/lingbib#rosettaType> datatype .
?doc <http://rosettaproject.org/lingbib#refersToLanguoid> ?lang
}
Example GraphPath Query
def documents_of_type_within(self, language, datatype, context=lingbib):
result= []
languages = []
for l in self.pop_graph>>Node(URIRef(language))//Property(self.isMotherOf):
languages.append(URIRef(l))
result = self.documents_of_type_in(languages, datatype, context)
return result
def documents_in(self, languages, context=lingbib):
result = []
for p in self.pop_graph>>Any()[Property(self.refersToLanguoid)/Nodes(languages)]:
result.append(p)
return result
def documents_within(self, language, context=lingbib): # provide a region arg?
result= []
languages = []
for l in self.pop_graph>>Node(URIRef(language))//Property(self.isMotherOf):
languages.append(URIRef(l))
result = self.documents_in(languages, context)
return result