jQuery Client

Access JSONpedia with Javascript

How to include it


<script type="text/javascript" src="js/jquery-1.7.2-min.js"></script>
<script type="text/javascript" src="js/jsonpedia.js"></script>

How to use it

Live annotation


    var c = new JSONpedia();
    c.annotate('en:Albert_Einstein').extractors()
            .linkers().splitters().structure().validate()
            .json()
            .done(
                function (data) {
                    console.log('Success: ' + data);
                }
            )
            .fail(
                function(err) {
                    console.error('Something went wrong: ' + err);
                }
            );

MongoDB query


    var c = new JSONpedia();
    c.mongo().select('_id = #736 -> title', '@type : link', 1)
            .done(
                function (data) {
                    console.log('Loaded data: ' + data);
                }
            )
            .fail(
                function(err) {
                    console.error('Error while loading data: ' + err);
                }
            );

MongoDB Map/Reduce


    var c = new JSONpedia();
    c.mongo().mapred(
            '_id = #736',
            'function() { ocs = this.content.templates.occurrences; for(template in ocs) { emit(template, ocs[template]); } }',
            'function(key, values) { return Array.sum(values) }',
            10)
            .done(
                function (data) {
                    console.log('Loaded data: ' + data);
                }
            )
            .fail(
                function(err) {
                    console.error('Error while loading data: ' + err);
                }
            );

Elasticsearch query


    var c = new JSONpedia();
    c.elastic().select('Albert Einstein', '@type : link', 1)
            .done(
                function (data) {
                    console.log('Loaded data: ' + data);
                }
            )
            .fail(
                function(err) {
                    console.error('Error while loading data: ' + err);
                }
            );

Tests cases

The test cases are available here.