Motivation

We are increasingly dealing with Linked Data, witnessing how Internet is turning into a Web of Data, a huge DataBase with very different sets of data linked together and available online. We thought we could use this information not only to find answers, but also to automatically generate questions… for a quiz that could be played.

The opportunity

Even though we had the quiz-using-linked-data idea some time ago, the 10K Apart contest (challenge: build a web app in less than 10 kilobytes) was a good opportunity to showcase the power of having so much information available, building something with millions of questions by just writing a few lines of code…

The contest is full of great html5 demos, so we wouldn’t expect our app being a winner. Anyway, feel free to support our entry by giving us a vote! 🙂

Here’s a screenshot of our app:

The topic

In order to submit the app to the contest (and also to fit everything in 10K), we had to focus. And yes, there would be many interesting questions to be generated thanks to information made available from open governments… but we thought that asking questions about cinema would be a much better option for a light quiz. Plus, we had the chance of using the Linked Movie DataBase, which has information about tens of thousands of movies and actors… Plenty of cinema questions could be generated with that!

We decided to let the user choose an actor or actress, and generate a quiz with questions about the movies where he or she has appeared.

What kind of questions are generated? Some of them are pretty straightforward to create: For example, the director and release date of a particular film are easily related to the actor (See image on the right). Then it’s only a matter of giving other dates as options, or other directors of movies where the actor or actress has acted.

For other questions, there are more relations involved. For instance, the application asks which character did the actor or actress play in a particular movie (“performance 1” in the following image), giving as other options another character in the same movie, played by another actor (“performance 2”), another character played by the same person but in another movie (“performance 3”), and another character played by a different person in a different movie (“performance 4”).

The next two images depict a question of this kind generated by the application about Marlon Brando, before answering, and after a successful response:

The development

The LMDB exposes the data through a SPARQL endpoint, which was very convenient for our purposes. With just a few queries, the application is able to retrieve the information needed to generate a quite decent set of questions. The following lines illustrate a query used to retrieve information about all the movies an actor or actress has appeared in (the title, the name of the character played, the name of the director, and the links to the IMDB and Freebase websites, if available).

PREFIX movie:<http://data.linkedmdb.org/resource/movie/>

PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>

PREFIX foaf:<http://xmlns.com/foaf/0.1/>

PREFIX dc:<http://purl.org/dc/terms/>

SELECT DISTINCT ?title ?char ?dirName ?date ?imdb ?fb WHERE {

?film movie:actor <**actorUri**>;

rdfs:label ?title.

OPTIONAL {?film movie:director ?dir. ?dir movie:director_name ?dirName }

OPTIONAL {?film dc:date ?date.}

OPTIONAL {?film foaf:page ?imdb.

FILTER regex(str(?imdb), "^http://www.imdb.com/title", "i" )}

OPTIONAL {?film foaf:page ?fb.

FILTER regex(str(?fb), "^http://www.freebase.com", "i" )}

OPTIONAL {

<**actorUri**> movie:performance ?perf.

?film movie:performance ?perf.

?perf movie:performance_character ?char.

}

}

Importantly enough, the 10K contest implied other limitations in addition to the code size: As client-side code is being used, it was kind of tricky to grab the information directly from the browser. Luckily, using jQuery in combination with YQL we could sort out this issue, also benefiting from its caching advantages, as we are particularly worried about knocking the LMDB down.

Of course, we are aware there are bugs (known issues with IE6 and IE7), and we are aware that sometimes there are problems accessing the data; let’s see how it goes once this is publicly available… Also, some of the answers might not be accurate (sometimes we’ll be responsible; sometimes we will just say it’s the data;) Anyway, do not blame us if you feel some answers are not well evaluated. (Disclaimer: We are not responsible if you get involved in some kind of underground bet involving money!:)

And do not hesitate to contact us with questions and comments. (We’ll try to upload the unminified code somewhere soon too.)

Acknowledgements

We would like to thank Oktie Hassanzadeh and the LMDB team for being supportive. Plus, in extension, thanks to the whole Linked (Open) Data crowd.

Additionally, we are grateful to the YDN and its YQL. In particular, Christian Heilmann (@codepo8) has lately been an inspiration in terms of how to easily build a webapp with external content.

Our cousin Pablo is responsible for many cosmetic changes in the webapp. We’re really glad about this yet-another-collaboration with him. 🙂

Finally, María Rodri and María Ipa, and our colleagues at iSOCO and Buongiorno are to thank for their valuable feedback and support.

…

Happy quiz!