Skip to content

Commit

Permalink
fixed dbpedia examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Germesin committed Feb 14, 2012
1 parent 46e9c7d commit ad82ed3
Showing 1 changed file with 29 additions and 43 deletions.
72 changes: 29 additions & 43 deletions index.html
Expand Up @@ -84,20 +84,15 @@ <h3><a href="#">Tell you how tall is the Eiffel tower</a></h3>
);
v.load({
entity : eiffel
}).using("dbpedia").execute().done(function (a) {
_.each(a, function (entity, key) {
if (entity.id !== '<' + eiffel + '>') {
return true;
}
var height = {
year: entity.get(heightByYear)[0],
height: entity.get(heightByYear)[1],
}
height.height = height.height.substr(2, 7);
jQuery('#towerheight .resultsholder').append(
jQuery("<p>Eiffel Tower, at " + height.year + " was " + height.height + " tall. We also know " + Object.keys(entity.attributes).length + " other facts about the tower.</p>")
);
});
}).using("dbpedia").execute().done(function (entity) {
var height = {
year: entity.get(heightByYear)[1],
height: entity.get(heightByYear)[0],
};
height.height = height.height.substr(2, 7);
jQuery('#towerheight .resultsholder').append(
jQuery("<p>Eiffel Tower, at " + height.year + " was " + height.height + " tall. We also know " + Object.keys(entity.attributes).length + " other facts about the tower.</p>")
);
});
</textarea>
<button>Run</button>
Expand All @@ -114,40 +109,31 @@ <h3><a href="#">Find you what is the capital of Mongolia</a></h3>

var mongoliaURI = "<http://dbpedia.org/resource/Mongolia>";
var capitalPropURI = "<http://dbpedia.org/property/capital>";
var namePropURI = "rdfschema:label";
var namePropURI = "rdfs:label";

vie
.load({entity : mongoliaURI})
.using('dbpedia')
.execute()
.done(function (entities) {
_.each(entities, function (e) {
if (e.id === mongoliaURI) {
var capitalURI = e.get(capitalPropURI).id;
vie
.load({entity : capitalURI})
.using('dbpedia')
.execute()
.done(function(capitalEntities) {
_.each(capitalEntities, function(entity) {
if (entity.id != capitalURI) {
return true;
}
var url = entity.id.substr(1, entity.id.length - 2);
var label;
_.each(entity.get('rdfschema:label'), function(labelLang) {
if (labelLang.substr(-2) === 'en') {
label = labelLang.substr(2, labelLang.length - 7);
}
});

jQuery('#mongolia .resultsholder').append(
jQuery('<p>The capital of Mongolia is <a href="' + url + '">' + label + '</a>.</p>')
);
});
});
}
});
.done(function (mongolia) {
var capitalURI = mongolia.get(capitalPropURI);
vie
.load({entity : capitalURI})
.using('dbpedia')
.execute()
.done(function(capital) {
var url = capital.id.substr(1, capital.id.length - 2);
var label;
_.each(capital.get(namePropURI), function(labelLang) {
if (labelLang.substr(-2) === 'en') {
label = labelLang.substr(2, labelLang.length - 7);
}
});

jQuery('#mongolia .resultsholder').append(
jQuery('<p>The capital of Mongolia is <a href="' + url + '">' + label + '</a>.</p>')
);
});
});
</textarea>
<button>Run</button>
Expand Down

0 comments on commit ad82ed3

Please sign in to comment.