-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
78 lines (69 loc) · 2.12 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html>
<head>
<title>Test page for DBpedia spotlight</title>
<script src="https://code.jquery.com/jquery-1.12.1.min.js"></script>
<meta charset="UTF-8">
</head>
<body>
<text id="text">Super Mario Galaxy
</text>
<button id="Bouton">Launch dbpedia request</button>
<button id="Bouton2">SPARQL TEST</button>
<span id="result">
result
</span>
</body>
<script>
$("#Bouton").click(function test(){
$.ajax({
url: 'http://model.dbpedia-spotlight.org/en/annotate',
type: 'GET',
data: {
text: document.getElementById("text").textContent,
confidence: 0.5,
},
dataType: 'json'
})
.done(function(data) {
console.log(data);
document.getElementById("result").innerHTML = data;
})
.fail(function() {
console.log("fail");
})
.always(function() {
});
});
var url = "http://dbpedia.org/sparql";
var query = "\
SELECT * WHERE {\
<http://dbpedia.org/resource/Super_Mario_Galaxy> ?p ?v .\
}\
LIMIT 200";
var queryUrl = encodeURI( url+"?query="+query+"&format=json" );
$("#Bouton2").click(function test2(){
$.ajax({
dataType: "jsonp",
url: queryUrl,
success: function( _data ) {
var results = _data.results.bindings;
for ( var i in results ) {
var res = results[i].abstract.value;
alert(res);
}
}
})
.done(function(data) {
console.log(data);
})
.fail(function() {
console.log("fail");
})
.always(function() {
})
})
</script>
<script type="text/javascript">
</script>
</html>