Be Present Now

durdn is here talking about tech stuff. or so he says.

A webapp in 1 week (part 2): the source of data

In the first installment of this series I've spoken about a set of technologies that can speed up the time to market quite a bit. Read about it here if you missed it.

This time I want to talk about where to get the content for your niche web app - if you need a source of content, that is. Leverage the Semantic Web I apologize if you all know it and I am late to the news.

But really, the semantic web is alive and here and I think one of its most promising incarnations is Freebase.

What is Freebase? Take the whole of Wikipedia, in it's unstructured - well I should say semi-structured - mass of data, structure it properly creating schemas on schemas of semantic relations amongst articles, and expose a clean API on top of it.

Keep the openness part, allow anyone to create new domains (called bases) and to contribute structured content by hand or programmatically. That is freebase as I understand it. 

Beautiful. How did I use it So the secret is out, that's exactly what I used to present cool thumbnails and basic movie data for my tiny tuttivisti - now at the second week of life (check it out by the way, the new release is out).

Let me go into deeper depth here because I realize the audience requires it. The Freebase folks have extensive documentation on how to interact with their service. In addition to that they publish two very nice Python libraries, freebase-suggest and freebase-python. The first to add a cool, jquery based autocompletion dropdown to your forms, the second to query Freebase programmatically from a Python program.

freebase-suggest example Using the freebase-suggest library is very easy. To achieve this:

"tuttivisti autocompletion"

I just had to add this jquery snippet to the bottom of the page:

<script type="text/javascript">
    var options = { soft: false, 
                    ac_param: { 
                        type: '/film/film',
                        category: 'instance',
                        disamb: '1',
                        limit: '10'
                    }
                  };
    $('#searchbox') .freebaseSuggest(options) .bind('fb-select', function(e, data) { 
        $('#searchbox').val(data.name);
        $('#freebase_id').val(data.id);
        $('#freebase_image_id').val(data.image.id);
        $('#search_movie_form').submit(); 
        return false;
    });
</script>

And mark the text input of the search with id="searchbox".

The freebase-python library is also very easy to use and I encourage you to take a look at the documentation, here. So in conclusion, before your app gains traction and your content is produced by your users, leverage the Semantic Web if you can, use freebase!

18 November 2008

comments powered by Disqus