Semantic Forms in Drupal: Making the Semantic Web Usable

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

Are there any current initiatives for semantic forms in Drupal?

A more detailed explanation

'Semantic Forms' is somewhat vague, so let me clarify.

When I say 'semantic form', I'm talking about a form that would make it easy for people to use semantic identifiers as values in form fields.

Ideally I would like to make it possible for normal people to select terms from a list of human-readable labels, and then save the machine-readable identifiers which correspond to those labels.

I have a need for this in the library where I work. We are trying to create linked collections. But it is currently difficult to do this because staff members would need to cut-and-paste URIs. They also don't have an intuitive way to understand what a URI represents when they look at record's page.

Examples

For example, say I have a form with one field: US State.

The field's widget is an autocomplete text box. When you start typing in the autocomplete you get a list of states. When you select a state, the state's human readable-name (e.g. 'Maine') is stored as the textbox's value, *and* (here's the key bit) the state's semantic identifier (e.g. 'http://dbpedia.org/data/Maine.xml') is saved as an attribute to the textbox e.g. <input class="autocomplete" type="text" ... semantic_uri="http://dbpedia.org/data/Maine.xml' ... > )

Another Example: Freebase.com

This is what is already being done at http://freebase.com. When you edit a property in a freebase topic, the value of the property often has a Freebase ID and a human-readable label. On Freebase the human-readable label is displayed in the property's textbox, and the Freebase ID is stored as an attribute on the textbox, 'fb__id'.

I presume this works because Freebase's back-end form handlers are programmed to take the semantic ID value from the 'fb__id' attribute on input elements.

Semantic Forms in Media Wiki: Not Quite the Same Thing

A side note: MediaWiki does have something called 'Semantic Forms': http://www.mediawiki.org/wiki/Extension:Semantic_Forms . I'm not sure that this is quite the same thing as I'm talking about here

Ideal Flow In Drupal

Ideally I would like to work out a standard way for doing something similar in Drupal.

The flow I have in mind is something like this:

  1. Site admin configures form fields, has widget for field_X be a semantic autocomplete, pulling from vocabulary Y. Vocabulary Y consists of terms w/ a 'label' field and a 'URI' field. (this could also be generated dynamically via SPARQL)
  2. User enters data on the resulting form. Selects a choice from the autocomplete on field_X. Choice's label is displayed to user on editing form, and choice's URI is saved as the value of 'semantic_URI' attribute on the input for field_X.
  3. User submits form. Drupal semantic form handler extracts value of the 'semantic_URI' attribute on semantic form widgets and saves those as the value of the fields.
  4. User views data generated by form. Can view 'raw' data view (w/ semantic URI values), or can view human-readable view (queries semantic URIs to get labels).

Implementing This?

I am possible interested in doing this. It depends on how much time it would take, and whether I can justify doing it as part of my normal job.

Questions

  1. Is anyone else working on something like this, in Drupal or other systems?
  2. Does anyone else have a need for this?
  3. Is anyone else interested in working on this?
  4. Any feedback on how to do this?

Comments

SPARQL autocomplete

scor's picture

I once wrote a custom module which did something similar. It was a CCK field in Drupal 6 which was querying a SPARQL endpoint with the string you typed, displaying the resources label in the drop down list of choices, and using the URI as value of the field (once you selected a item in the list). It was around the time of DrupalCon DC 2009. I remember Lin got pretty excited about it, and asked me to contribute it, but I never found the time to do it :( sorry Lin...

It was not complicated, and I bet with the RDF/SPARQL goodies we now have in D7, it'd be even easier.

re e.g. <input class="autocomplete" type="text" ... semantic_uri="http://dbpedia.org/data/Maine.xml' ... >, I would recommend to use a hidden form elements instead, it would work much better with the FAPI than a custom attribute.

Another way to do it is like the node/user references: insert the URI in bracket after the label, and parse it on form submission, Maine [uri:http://dbpedia.org/resource/Maine]

If I'm not mistaken, most of

linclark.research's picture

If I'm not mistaken, most of this can be covered by Drupal APIs that are already in place. The trick in a lot of use cases like this is to understand that most of the work the Web application does doesn't need to be SemWeb-y... the RDF just needs to leverage the functionality that is already there.

Based on your description, here are some thoughts:

Ideally I would like to make it possible for normal people to select terms from a list of human-readable labels, and then save the machine-readable identifiers which correspond to those labels.

This is what Drupal's autocomplete does. You should be able to use something like References module for an example, you would just switch out the $nid part with a full URI.

1. Site admin configures form fields, has widget for field_X be a semantic autocomplete, pulling from vocabulary Y. Vocabulary Y consists of terms w/ a 'label' field and a 'URI' field. (this could also be generated dynamically via SPARQL

There is currently no way to elegantly populate an autocomplete using a SPARQL query. You can probably do something by stringing together SPARQL Views and some connector between autocomplete and Views (there was a way to do that in D6 at least), but I haven't looked into it at all.

User views data generated by form. Can view 'raw' data view (w/ semantic URI values), or can view human-readable view (queries semantic URIs to get labels).

I imagine that this kind of functionality is covered by other autocompletes. Take a look, what you'd be looking for is two field_formatters, I believe, which could be used on different display types.

Thanks for the Tips

adorsk's picture

@scor, @linclark

Thanks for the tips! After reading your suggestions this idea seems much more feasible than I first thought. I'll give it a shot.

What about linking a MW site with drupal site?

brucewhealtonjr's picture

I was starting to develop a genealogy site in MediaWiki. We might even have to extend some existing vocabularies or ontologies, such as FOAF, BIO and maybe REL. Anyway I did want to do this in both MediaWiki and Drupal, as initially, I couldn't decide what tool was best for this. The Semantic Forms with SMW are great. It's too bad the MediaWiki project hasn't been maintained since drupal 5. I wonder if it would be posssible to share data, including semantic property mappings between both systems?
Anyone have any thoughts? Or thoughts on this kind of project overall and how this could best be approached?

It would be good if properties like father, grandfather, descendent, and ancestor are used consistently in both software systems and present the same triples.

For the purpose of data sharing and discovery, does the data need to be output in RDF format? Or are applications and tools able to work with RDFa? I don't know if we would need to export the data as RDF and how? How often?
Thanks,
Bruce

Hi Bruce, I think the

linclark.research's picture

Hi Bruce,

I think the question deserves to be its own thread, so I'd recommend making another post. You might want to describe what parts are in MediaWiki and what parts are in Drupal, that will help understand what kind of integration is needed.

-Lin

Semantic Web

Group organizers

Group notifications

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