RDF: Difference between revisions

From Meta, a Wikimedia project coordination wiki
Content deleted Content added
first brainstorming
 
→‎Scope: custom RDF
Line 17: Line 17:


This will probably implemented as an extension that provides a special page which, wehn called without parameters, would present a form where the user can specify what data is wanted in what format.
This will probably implemented as an extension that provides a special page which, wehn called without parameters, would present a form where the user can specify what data is wanted in what format.

Another possible feature would be to allow users to add custom RDF information on any page, in Turtle format, in a <nowiki><rdf>...</rdf></nowiki> block


== Implementation ==
== Implementation ==

Revision as of 18:05, 3 June 2005

This page is about an effort to provide an extensive RDF interface for mediawiki. The idea is to create a flexible framework that goes byond the ability of the code described at RDF metadata. I (User:Duesentrieb) am working on this together with User:Evan.

Scope

The idea is to provide a way to query different kinds of information about a wiki page in RDF format. This may include

  • basic metadata as defined by the Dublin Core standard and/or the Creative Commons project.
  • List of all authors
  • List of all links to and from a page
  • List of keyworkds (Categories for a page)
  • List of members of a category
  • ...and a plugin interface for more.

Also, the RDF could be deliver in different notations, like

  • RDF/XML
  • N-Tripel
  • Turtle
  • ..and my be others.

This will probably implemented as an extension that provides a special page which, wehn called without parameters, would present a form where the user can specify what data is wanted in what format.

Another possible feature would be to allow users to add custom RDF information on any page, in Turtle format, in a <rdf>...</rdf> block

Implementation

The implementation will probably be based on the RAP framework [1]. The core function will take a list of "models", i.e. datasets wanted, and return a RAP model which can then be serialized to create the actual output.

Here is the code for that function, as suggested by User:Evan:

 function getRdf($article, $modelNames=$wgDefaultModelNames) {
   global $wgModelFunctions;

   #empty model

   $fullModel = new RAP::Model();

   for ($modelNames as $modelName) {
        $modelFunction = $wgModelFunctions[$modelName];
        if ($modelFunction == null) {
             #print error
             continue;
        }
        $model = $modelFunction($article);
        $fullModel->merge($model);
   }

   return $fullModel;
 }
 

$wgModelFunctions may be changed to contain a human readable description of the data set in addition to the function name. This would the be displayed on the query form where the user can choose the data sets.

Here's an exampel function for creating Dublin Core base data (code suggested by User:evan):

 function DublinCoreModel($article) {
    global $DC_creator, $DC_date; # available from RAP system

    $model = new Model();

    $resource = getArticleResource($article); # Gets a RAP resource for the article; we'll have some utilities like this
    $user = getUserResource($article->getUser()); # another utility

    $model->add(new Statement($resource, $DC_creator, $user));
    $model->add(new Statement($resource, $DC_date, new Literal($article->getDate()));

    # etc.

    return $model;
 }
 

Example function for listing all links from a page (also suggested by User:evan):

 function LinkingModel($article) {
 
    global $DCMES, $DCTERM, $DCMI_types;
 
    $model = new Model();
 
    $resource = getArticleResource($article); # here's that utility again
 
    $linkFromTitles = $article->links(); # actually, I'm pretty sure this doesn't exist, but it should. B-)
 
    for ($linkFromTitles as $linkFromTitle) {
        $model->add(new Statement($resource, $DCTERM['References'], titleToResource($linkFromTitle));
    }
     
    $linkToTitles = $article->whatLinksHere(); # another function that never was
 
    for ($linkToTitles as $linkToTitle) {
        $model->add(new Statement($resource, $DCTERM['isReferencedBy'], titleToResource($linkToTitle));
    }
 
    # ... more for Image links, etc.
 
    return $model;
 }
 

It may however be better to have a more generic function that allows to build such a list directly from an SQL query. This would make it very easy to add new datasets.