RDFme: a RDF drupal module

Events happening in the community are now at Drupal community events on www.drupal.org.
FernandoTapiaRico's picture

Hi,
I've been developing a RDF module for Drupal. It was a part of my final thesis/project, and was created due to the lack of flexibility of the "RDF" module in Drupal 6.x. The module got the interest of some universities, national projects, etc and I would like to share it with the community.
I'm currently applying for a "full project access" and it would be nice to get some reviews. it's my first Drupal module and I'm sure that there will be some bugs or I didn't follow ALL the drupal code standards.
Here is the sandbox project where you can find more info: http://drupal.org/sandbox/FernandoTapiaRico/1085146
also on GitHub: https://github.com/fertapric/rdfme
I will appreciate any help/feedback/support
Cheers

Fernando Tapia Rico
www.fernandotapiarico.com
P.S: I also have an ideatorrent port.
P.S.2: I don't have any problem on porting the code to drupal 7 if people is interested on it.

Comments

Are you familiar with the RDF

linclark.research's picture

Are you familiar with the RDF CCK module or the work that went into putting RDF in Drupal core in Drupal 7?

Yeah, I'm familiar with the

FernandoTapiaRico's picture

Yeah, I'm familiar with the RDF CCK module. In fact, it was the base of my module. The problem with RDF CCK was the RDF mapping, that it was IMHO limited for the requirements of the thesis/project. If you try my module you will see that you can define subclasses, patterns. For example, this is an output from my module:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"   xmlns:gi2mo="http://purl.org/gi2mo/ns#"  xmlns:foaf="http://xmlns.com/foaf/0.1/"  xmlns:dcterms="http://purl.org/dc/terms/"  xmlns:marl="http://purl.org/marl/ns#">
  <gi2mo:Idea rdf:about="http://pgi2.atosorigin.es/node/286/rdf">
    <foaf:page rdf:resource="http://pgi2.atosorigin.es/node/286"/>
    <gi2mo:hasCreator rdf:resource="http://pgi2.atosorigin.es/user/60/rdf"/>
    <dcterms:created>1277633698</dcterms:created>
    <gi2mo:hasComment rdf:resource="http://pgi2.atosorigin.es/node/286/50/rdf"/>
    <dcterms:title>Nota media</dcterms:title>
    <gi2mo:hasCategory rdf:resource="http://pgi2.atosorigin.es/node/286/class/4/1/rdf"/>
    <gi2mo:hasCategory rdf:resource="http://pgi2.atosorigin.es/node/286/class/4/2/rdf"/>
    <marl:hasPolarity rdf:resource="http://purl.org/marl/ns#-1"/>
    <marl:polarityValue>-1.04407</marl:polarityValue>
    <gi2mo:hasStatus>Borrador</gi2mo:hasStatus>
    <gi2mo:hasReview rdf:resource="http://pgi2.atosorigin.es/node/286/class/3/rdf"/>
    <gi2mo:content>Aunque corresponde más a la upm virtual, me gustaría poder conocer cuál es mi nota media global o por curso, que resulta de gran ayuda para pedir becas, premios, ayudas... En ocasiones no es fácil saber si una asignatura de libre elección se considera en el cálculo de nota media, o que ocurre con las convalidaciones o las asignaturas que sólo son evaluadas con APTO.</gi2mo:content>
    <gi2mo:hasAttachment rdf:resource="http://pgi2.atosorigin.es/node/286/class/1/rdf"/>
  </gi2mo:Idea>
  <gi2mo:Attachment rdf:about="http://pgi2.atosorigin.es/node/286/class/1/rdf">
    <gi2mo:hasBinaryContent rdf:resource="http://pgi2.atosorigin.es/sites/default/files/idea/calificaciones.png"/>
  </gi2mo:Attachment>
  <gi2mo:Attachment rdf:about="http://pgi2.atosorigin.es/node/286/class/2/rdf">
    <gi2mo:hasBinaryContent rdf:resource="http://pgi2.atosorigin.es/node/286"/>
  </gi2mo:Attachment>
  <gi2mo:MinMaxRating rdf:about="http://pgi2.atosorigin.es/node/286/class/3/rdf">
    <dcterms:description>Ratings from Voting API module</dcterms:description>
    <gi2mo:maxRatingValue>0.94285714285714</gi2mo:maxRatingValue>
  </gi2mo:MinMaxRating>
  <gi2mo:Category rdf:about="http://pgi2.atosorigin.es/node/286/class/4/1/rdf">
    <dcterms:description>Categoria de la idea</dcterms:description>
    <dcterms:title>Secretaría</dcterms:title>
  </gi2mo:Category>
  <gi2mo:Category rdf:about="http://pgi2.atosorigin.es/node/286/class/4/2/rdf">
    <dcterms:description>Categoria de la idea</dcterms:description>
    <dcterms:title>Idea</dcterms:title>
  </gi2mo:Category>
</rdf:RDF>

I think you cannot have this kind of flexibility with RDF CCK.
You have an example instance at: http://www.fernandotapiarico.com/apps/rdfme-opal/

The menu:

  • Namespaces:same as RDF module, the base is an EVOC module modified. The reason of modified EVOC module was to retrieve the deprecated classes and properties (that info is used on the mapping)
  • Import RDF data:it imports node/comments in RDF/RDFa format. ARC library is required. That's the buggie part
  • Import/export RDF mapping:use to import/export the mappings to facilitate migration between systems.
  • RDF mapping:the main function of the module. It allows to map RDF properties to CCK and normal content. Same as RDF CCK, but with more options: patterns, subclasses, deprecated classes/properties checking and so on

Hope you enjoy the module
Cheers

Fernando

Hmmm, I tried the link

linclark.research's picture

Hmmm, I tried the link before, but your example instance just shows the default Welcome screen. You say that it allows you to define subclasses, but I don't see what you are talking about from your RDF/XML example... there is no rdfs:subClassOf relationship. As far as patterns, what kind of patterns are you referring to?

This is the second forked version of Evoc I've seen. It would be great if people would suggest changes to the module or use make files and patches instead of forking it every which direction. There aren't all that many developers working on this stuff, so if we want to make useful things we're going to have to combine our efforts and ensure we aren't duplicating code and work.

My recommendation would be to get active in the issue queues for the modules that you are extending. This module seems to duplicate a lot of code when it could just implement features in the existing modules. That way you won't have to figure out everything about coding a module all at once (like how to properly use the theme system) and you will be able to implement the features you want much faster.

use the "admin/admin" account

FernandoTapiaRico's picture

use the "admin/admin" account to login into the instance. Once you get logged into the platform, you will see a "Modules" block on the right side where you can find all the menu I described above.

The reason of forking EVOC was to have a module in a package, instead of: module + evoc + patch. I thought that it's a lot easier for the final user to have it in this way. I used RDF CCK as base, but now the module really differs from RDF CCK, that's why I didn't think on extending other modules.

and about the RDF/XML, AFAIK

FernandoTapiaRico's picture

and about the RDF/XML, AFAIK you cannot have several classes in the RDF export of a node. You can only map a Drupal node to a class, for example, in my RDF/XML "gi2mo:Idea", but you cannot map it's properties on different subclasses/classes like "gi2mo:Attachment" or "gi2mo:Category". You will see the patterns on the "RDF mapping" menu. At the end, you can use the patterns to customize the output of a value. For example, node 1 has a property "Category" which value is "facebook". The available "categories" are ["Twitter", "Facebook", "Google"], but, in your RDF output, you want to have this domains turned into URLs. So you can use this pattern "http://@@@value@@@.com" and the module will change @@@value@@@ for "facebook". Other patterns are (copied from the module):

Special markup

value : Value of the property
nid : Node identifier
uid : User identifier
url : base URL of the Drupal instance (http://www.fernandotapiarico.com/apps/rdfme-opal/)
id : Class identifier
cid : Comment identifier
Markups can be used on class URIs and property patterns. To use a markup follow the structure: @@@markup@@@

Hi Fernando, I logged into

milesw's picture

Hi Fernando,

I logged into the demo, and I see all the RDF mappings, but there is no Drupal content created yet. Apart from the import/export functionality, the main goal is to offer RDF representations of content, correct?

When I installed the module on my own system the layout of the RDF mapping forms was very broken. I assume this is because you developed using a custom theme. On your demo it looks good, but you should also ensure that it works well on Garland and other decent themes.

Another thing, I'm getting lots of PHP strict warnings. Ideally you want to turn on strict error reporting while developing.

This is quite an ambitious module. As Lin mentioned, it would be nice if code could be shared between other projects. You mentioned this is your first module, so maybe over time you could find ways to integrate with existing projects.

Overall, nice work though :)

Hi Miles, you are right,

FernandoTapiaRico's picture

Hi Miles,
you are right, apart from import/export functionality (when I say import, it means real import, from RDF to Drupal content), the main goal is to offer custom representations of the content. I wanted to have the same flexibility as you can have in the d2rq language. (Next step is translation tables, I've already imlemented this, but I thought that is better to release this version as an estable one, and later add the new features).

About the theme, I'm following (or I think so) the Drupal theme system. Now, I've changed the current theme to Garland on my instance and it looks ok. You can check it here: http://www.fernandotapiarico.com/apps/rdfme-opal/?q=admin/settings/rdfme.... I will keep this format until sunday. In addition, here you have an screenshot: http://www.fernandotapiarico.com/apps/images/rdfme/rdfme_mapping_garland...

About PHP warnings, could you give more information? (type of warning, version of PHP you are using, drupal version, etc). Besides, could you create an issue on either GitHub or Drupal (sandbox project). I will turn on strict error reporting, but, by now, it would be nice to have that feedback.

The problem of sharing code is the slow process to get your code accepted, and when I created this, as I said, it was part of my career's final project. I will create another comment with a comparative between my module and RDF CCK, and see how far you can go with both of them. You will see the reason I developed this.

Thanks for the feedback, it's really helpful.

Fernando Tapia Rico

I do encourage you to add the

linclark.research's picture

I do encourage you to add the comparison between your module and the existing RDF solutions to your module's page. It is very easy for users to get confused when it comes to RDF, and having multiple modules that say they do the same thing makes it even harder on the users. Here is an Open Letter that's in the Similar Module Review group, it does a good job of explaining the problems with having a bunch of different similar implementations and the possible solutions.

What you call patterns seems like it could be using tokens instead, http://drupal.org/project/token.

Also, the _rdfme_print_rdf function should be handled as a theme function. One of the great things about Drupal is its Presentation Abstraction Control architecture. To maintain the distinction between those parts, it is best to use theme functions whenever you are coding presentation layer things. There is a good presentation from DrupalCon San Francisco about Groking the Theme layer, you can find the video here and my notes on the presentation here. You can find out more about PAC architecture on Larry Garfield's blog (funny enough, if you google for PAC architecture, his is the third that comes up).

As for translation tables, you should look into how you can integrate with Drupal's native localization. I haven't done any real localization myself, so I don't know much about it, but that is one area that I know Drupal excels in and has very good modules for.

The amazing thing you get when you use Drupal is the ability to connect all these different modules together like Legos. This allows the community to standardize things like token handling so that users who install a new module don't have to learn a whole new way of replacing text... the user can just apply the knowledge that they already have about how tokens work. Beyond being a part of Drupal, this kind of programming is also a new trend in IT and CS, called integrative programming as reported in Communications of the ACM.

As Miles said, this is an ambitious project. I know how difficult it is to learn all the Drupal systems, I still struggle with it myself. I would really encourage you to start small with distinct feature requests that build on existing modules, it will really help you understand all the tools that you have available to you within Drupal and move much more quickly in your development. It will also help you meet other people who can help you develop the features you want to see.

Fernando, I posted an issue

milesw's picture

Fernando,

I posted an issue in your sandbox queue with a screenshot.

I do hope the feedback so far is taken positively and not as criticism. There's no doubt everyone appreciates you sharing your work. The concern I have, and I believe the concern behind Lin's comments, is that most modules not making good use of the Drupal APIs and well-established contrib modules often don't live long, happy lives. And it's always disappointing to see great development effort fade away when it could have contributed toward a standardized, sustainable solution.

It would be great if you could put together an RDF module comparison based on your experiences. I happen to be one of those people often confused about the current landscape of RDF tools for Drupal. :)

Hello, I want to know , why

Nasreddine's picture

Hello,
I want to know , why I can't create discussions on this group ?

Semantic Web

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: