-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
938 lines (773 loc) · 28.4 KB
/
index.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DBpedia Spotlight</title>
<script src="selector.js" type="text/javascript"></script>
<script src="jquery-1.6.1.min.js" type="text/javascript"></script>
<script src="dbpedia-spotlight-0.3.js" type="text/javascript"></script>
<script src="jquery.getUrlParam.js" type="text/javascript"></script>
<script src="ui/jquery.ui.core.js"></script>
<script src="ui/jquery.ui.widget.js"></script>
<script src="ui/jquery.ui.mouse.js"></script>
<script src="ui/jquery.ui.slider.js"></script>
<script src="ui/jquery.ui.dialog.js"></script>
<script src="ui/jquery.ui.tabs.js"></script>
<script src="ui/jquery.ui.position.js" type="text/javascript" charset="utf-8"></script>
<script src="ui/jquery.ui.draggable.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.uniform/jquery.uniform.min.js"></script>
<script src="jquery.json-2.2.js"></script>
<script src="jstree/jquery.jstree.js" type="text/javascript" charset="utf-8"></script>
<script src="autoresize.jquery.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="themes/base/jquery.ui.all.css">
<link rel="stylesheet" href="jquery.uniform/css/uniform.default.css" type="text/css" media="screen" charset="utf-8" />
<style>
body {
font-size: small;
font-family: "Myriad Pro", Verdana, Arial, sans-serif;
}
#text {
border: 0;
width: 100%;
height: 100%;
padding: 0;
margin: 0;
font-family: inherit;
overflow: auto;
font-size: 14px;
outline: none;
}
#text_container {
font-size: 14px;
background: #fff no-repeat bottom right;
}
#text_container.annotated {
background: #f0f0f0 none;
cursor:text;
overflow: visible;
}
#text_container div {
height: 100%;
padding-left: 1px;
}
#text_container div a, a, a:visited {
color: #135e6c;
}
#text_container {
background: transparent;
}
#text_container .annotation {
padding-left: 0;
display: inline;
}
#text_container, #action_container, #filter_infobox {
width: 700px;
border-radius: 5px;
border: 1px solid #ccc;
border-color: #ddd #eee #eee #ddd;
border-width: 1px 2px 2px 1px;
}
.container {
margin: 0px 50px;
padding: 8px;
position: relative;
clear: both;
}
#filter_infobox {
background: #fafafa;
text-align: center;
margin-top: 10px;
}
#text {
background: transparent;
}
#action_container {
height: 170px;
margin-bottom: 10px;
background: #fafafa;
height: auto;
clear: left;
float: left;
position: relative;
}
#instructions {
font-size: 80%;
color: #666;
text-align: left;
}
#action_options {
float: left;
}
#action_buttons {
height: auto;
vertical-align: top;
line-height: 100%;
position: absolute;
bottom: 8px;
right: 8px;
}
.highlight { background-color: red; }
.main {
width: 800px;
margin-top: 2em;
margin-left: auto;
margin-right: auto;
}
.option {
width: 308px;
margin-left: auto;
margin-right: auto;
margin-bottom: 12px;
}
#content {
background-color: #ffa;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
.bookmarklet p {
text-align: center;
}
.bookmarklet a {
display: inline;
font-weight: bold;
text-decoration: none;
color: #333;
cursor:move;
background: #fff url(bookmark.png) 2px 3px no-repeat;
border: 1px solid #bbb;
font-size: 12px;
text-align: left;
min-height: 12px;
vertical-align: middle;
height: 14px;
padding: 6px 6px 3px 20px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
#logo {
margin: 0 auto 20px auto;
display: block
}
a.ui-slider-handle {
outline: none;
margin-top: 0.1em;
}
.ui-slider .ui-slider-handle {
width: 0.9em;
height: 0.9em;
}
.slider {
margin: 0.2em 0.45em 0 0.45em;
width: 250px;
height: 8px;
}
#confidence, #support, #context {
float: right;
width: 30px;
margin-top: 1em;
margin-left: 1.5em;
}
div.annotation:hover ul.candidates {
visibility: visible;
}
div.annotation {
position: relative;
overflow: visible;
}
#text_container .annotation {
color: #135E6C;
}
#text_container .filtered {
color: #666;
text-decoration: none;
}
#text_container a.filtered:hover {
text-decoration: underline;
}
#text_container div.filtered {
color: #666;
background: transparent;
text-decoration: none;
}
#text_container div.filtered a.surfaceForm {
color: #666;
background-color: #F2F2F2;
text-decoration: none;
}
ul.candidates {
font-size: 100%;
width: auto;
margin: 0;
padding: 0.2em 0 0 0;
left: 0;
top: 1.15em;
display: block;
position: absolute;
visibility: hidden;
z-index: 10;
border: 1px solid #e6e6e6;
border-right-width: 2px;
border-radius: 3px;
}
ul.candidates li {
list-style: none;
margin: 0;
padding: 0;
border-width: 0 0 1px 0;
border-style: solid;
border-color: #e6e6e6;
background: white;
white-space: nowrap;
padding: 0.15em 0.2em;
}
#text_container ul.candidates li a {
display: inline-block;
}
#text_container div a.surfaceForm {
display: inline-block;
padding: 0 3px;
border-radius: 3px;
padding-right: 12px;
border: 1px solid #f0f0f0;
background: white 95% 50% no-repeat url(data:image/gif;base64,R0lGODlhBQADAIABAHulrf///yH5BAEAAAEALAAAAAAFAAMAAAIFhB0XC1sAOw==);
cursor:default;
}
#text_container div div.annotation:hover a.surfaceForm {
border-color: #c0c0c0;
background-image: url(data:image/gif;base64,R0lGODlhBQADAIABAEJ+if///yH5BAEAAAEALAAAAAAFAAMAAAIFhB0XC1sAOw==);
}
ul.candidates li.candidate-0 {
padding: 0.15em 0.85em 0.15em 0.2em;
}
#tree_id a {background: transparent; border: none;}
body .jstree-default.jstree-focused {
background: transparent;
}
body .jstree li {
line-height: auto;
font-size: 12px;
}
#type_selector ul {
margin: 0;
padding: 0;
}
.tree {
list-style: none;
padding: 0;
margin: 0;
}
#sparql_type {
width: 100%;
height: 150px;
}
#edit_text_wrapper {
text-align: right;
width: 100%;
clear: both;
padding-top: 2em;
}
#edit_text {
display: none;
}
.copyright {
color: #666;
font-size: 80%;
text-align: center;
}
#filterPolicy {
text-align: center;
padding: 0.5em 0;
}
#text_annotated {
whitespace: pre-line;
}
#status_indicator {
width: 20px;
height: 20px;
display: inline-block;
background: none transparent;
}
#status_indicator.loading {
background-image: url(data:image/gif;base64,R0lGODlhEAAQAPQAAPr6+mZmZvHx8bW1tejo6I2Nja2trWZmZpiYmHp6esnJydTU1HBwcMDAwGdnZ4WFhaKiogAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAKAAAAIf8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LEMV34tELyRYNEsCQyHlvWkGCzsPgMCEAY7Cg04Uk48LAsDhRA8MVQPEF0GAgqYYwSRlycNcWskCkApIyEAOwAAAAAAAAAAAA==);
background-position: 50% 50%;
background-repeat: no-repeat;
}
.hidden {
display: none;
}
#flag {
width: 133px;
height: 70px;
}
</style>
<script>
var annotated = false;
var textInput = null;
//Default value:
var server = 'http://spotlight.sztaki.hu:2222/rest'
var res_prefix = 'http://dbpedia.org/resource/'
function select_language(uri, text, lang) {
$('#text').val(text);
$('#webservice').text(uri);
server = uri;
if (lang == "en")
res_prefix = "http://dbpedia.org/resource/"
else
res_prefix = "http://"+lang+".dbpedia.org/resource/"
}
var lastResponse;
function run(method) {
$('#edit_text_wrapper').show();
var settings = {
'endpoint' : server,
'confidence' : $('#confidence').val(),
'support' : $('#support').val(),
'powered_by': 'no',
'showScores': 'yes',
'spotter' : "Default",
'disambiguator' : $('#disambiguator').val(),
'policy' : getFilterPolicy(),
'callback' : function callback(response) {lastResponse = response; $('#status_indicator').removeClass("loading");}
}
settings.sparql = getSPARQLQuery();
settings.types = getTypes();
// will hide text object and show annotated text
$('#text').hide();
$('#text_annotated').remove();
$('#text_container').prepend('<div id=text_annotated>'+$('#text').val().replace(/\n/g, "<br />\n")+'</div>');
$('#text_annotated').annotate(settings);//TODO enable annotate(method, settings)
$('#text_annotated').annotate(method);
$('#status_indicator').addClass("loading");
$('#text_container').addClass("annotated loading");
$(".action_button").attr("disabled", true);
$.uniform.update(".action_button");
//button to get the editable text box back for the user to modify as needed
$('#edit_text').click(function() {
annotated = false;
$('#text_annotated').cancelAnnotation();
$('#text').show();
$('#text_annotated').remove();
$('#text_container').removeClass("annotated loading");
$('#status_indicator').removeClass("loading");
//$("#text_container").unbind('click');
$(".action_button").attr("disabled", false);
$('#edit_text_wrapper').hide();
$.uniform.update(".action_button");
});
annotated = true;
//get candidates for the surface form selected
$("#text_annotated").bind("mouseup", getSuggestions);
}
function getTypes() {
var checked_ids = [];
$("#tree_dbpedia").jstree( "get_checked" ).each(function () {
checked_ids.push("DBpedia:" + this.id);
});
$("#tree_freebase").jstree( "get_checked" ).each(function () {
checked_ids.push("Freebase:" + this.id);
});
$("#tree_schema").jstree( "get_checked" ).each(function () {
checked_ids.push("Schema:" + this.id);
});
return checked_ids.join(",");
}
function getSPARQLQuery() {
return $('#sparql_type').val();
}
function getFilterPolicy() {
if($('input[name=filterPolicy]:checked').val() == "blacklist")
return "blacklist";
else
return "whitelist";
}
function getSuggestions(eventObject){
var st = ''+Kolich.Selector.getSelected();
//console.log(st);
if(st!=''){
//console.log("You selected:\n"+st);
$("#suggestdialog").hide().text($('#text').val());
$('#suggestdialog').annotate("suggest");
$('#suggestdialog').show(); //TODO instead of a div on the bottom, make it a popup
/*$('<div></div>').dialog({
width: 100,
height: 200,
autoOpen: true,
position: [eventObject.pageX, eventObject.pageY],
title : "Candidates..."
});*/
} else {
$("#suggestdialog").hide();
}
}
function runWithSettings() {
if($("#nbest").is(':checked')){
run('candidates');
} else {
run('best');
}
}
// Override the onload event
$(document).ready(function() {
$('#edit_text_wrapper').hide();
//accept parameters from URL
var t = $(document).getUrlParam('text');
var execute = ($(document).getUrlParam('execute') == "yes");
if ($.trim(t)!='' && t != "null") { $('#text').val(decodeURIComponent(t)); }
$('textarea#text').autoResize({
// On resize:
onResize : function() {
$(this).css({opacity:0.8});
},
// After resize:
animateCallback : function() {
$(this).css({opacity:1});
},
// Quite slow animation:
animateDuration : 150,
// More extra space:
extraSpace : 15
});
$('#annotate').click(function() {
runWithSettings();
});
$("#support-slider").slider({
value:0,
min: 0,
max: 1000,
step: 10,
change: function( event, ui ) {
$( "#support" ).val( ui.value );
if(annotated)
filterAnnotations();
}
});
$( "#support" ).change(
function() {
$("#support-slider").slider("value", $( "#support" ).val());
}
);
$("#confidence-slider").slider({
value:0.5,
min: 0,
max: 1,
step: 0.05,
change: function( event, ui ) {
$( "#confidence" ).val( ui.value );
if(annotated)
filterAnnotations();
}
});
$( "#confidence" ).change(
function() {
$("#confidence-slider").slider("value", $( "#confidence" ).val());
}
);
$("#context-slider").slider({
value:0.0,
min: 0,
max: 1,
step: 0.1,
change: function( event, ui ) {
$( "#context" ).val( ui.value );
if(annotated)
filterAnnotations();
}
});
$( "#context" ).change(
function() {
$("#context-slider").slider("value", $( "#context" ).val());
}
);
function filter(occ, minConfidence, minSupport, minContextualScore) {
var squaredConfidence = minConfidence*minConfidence
//console.log(occ);
var support = parseInt(occ["support"]);
var contextualScore = parseFloat(occ["contextualScore"]);
var finalScore = parseFloat(occ["finalScore"]);
var percentageOfSecondRank = parseFloat(occ["percentageOfSecondRank"]);
//console.log( "support: " + support + " < " + minSupport +
// " || contextualScore: "+ contextualScore + " < " + minContextualScore +
// " || finalScore: "+ finalScore + " < " + simThreshold +
// " || percentageOfSecondRank: " + percentageOfSecondRank + "<" + (1-squaredConfidence));
return ( (support < minSupport) ||
//(finalScore < simThreshold) ||
//(contextualScore < minContextualScore) ||
(percentageOfSecondRank > (1-squaredConfidence)) );
}
function filterAnnotations() {
var minSupport = parseInt($( "#support" ).val());
var minConfidence = parseFloat($( "#confidence" ).val());
var minContextualScore = parseFloat($( "#context" ).val());
$(".annotation").each(function() {
var occ = { 'support': parseInt($(".support", $(this)).text()),
'finalScore': parseFloat($(".finalScore", $(this)).text()),
'contextualScore': parseFloat($(".contextualScore", $(this)).text()),
'percentageOfSecondRank': parseFloat($(".percentageOfSecondRank", $(this)).text()) }
//console.log(occ);
if (filter(occ, minConfidence, minSupport, minContextualScore)) {
$(this).addClass("filtered");
} else {
$(this).removeClass("filtered");
}
});
}
$('#annotation_language').change(function() {
var current_data=$("body").data($(this).val());
select_language(current_data.endpoint, current_data.content, $(this).val());
});
$.ajax({
type: "GET",
url: "config/sites.xml",
dataType: "xml",
success: function(xml){
var selectLanguage = $('#annotation_language');
$(xml).find('site').each(function(){
var i18n = $(this).find('i18n').text();
var language = $(this).find('language').text();
var url = $(this).find('url').text();
var text = $(this).find('text').text();
$("body").data(i18n, { content: text, endpoint: url });
selectLanguage.append($('<option></option>').val(i18n).html(language));
});
selectLanguage.trigger("change");
}
});
$("#method").change(
function() {
if(annotated){
runWithSettings();
}
}
);
$(".candidates").uniform()
$("select, input").uniform();
$("select, input").attr("disabled", false);
$(".disabled").removeClass("disabled");
$(".action_button").attr("disabled", false);
$("#tree_dbpedia").jstree({
"plugins" : [ "themes", "json_data", "checkbox" ],
"themes" : {
"icons" : false
},
"json_data" : {
"ajax" : {
"url" : "tree.dbpedia.json",
"data" : function (n) {
return { id : n.attr ? n.attr("id") : 0 };
}
}
}
});
$("#tree_freebase").jstree({
"plugins" : [ "themes", "json_data", "checkbox" ],
"themes" : {
"icons" : false
},
"json_data" : {
"ajax" : {
"url" : "tree.freebase.json",
"data" : function (n) {
return { id : n.attr ? n.attr("id") : 0 };
}
}
}
});
$("#tree_schema").jstree({
"plugins" : [ "themes", "json_data", "checkbox" ],
"themes" : {
"icons" : false
},
"json_data" : {
"ajax" : {
"url" : "tree.schema.json",
"data" : function (n) {
return { id : n.attr ? n.attr("id") : 0 };
}
}
}
});
$(".tree").jstree("set_theme","default");
$("#type_selector").dialog({
width: 750,
height: 520,
autoOpen: false,
position: ['center', 50],
title : "Select types…",
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
var filteredBy;
if(getSPARQLQuery() != "") {
filteredBy = "<strong>Filtered by SPARQL query</strong>";
if(filteredBy)
filteredBy += " (" + getFilterPolicy() + ").";
}else if(getTypes() != "") {
var typeFilterSetting = "<strong>Only showing the types:</strong> ";
if(getFilterPolicy() == "blacklist")
typeFilterSetting = "<strong>Showing none of the types:</strong> ";
filteredBy = typeFilterSetting + getTypes().replace(/,/g, ", ");
}
if(filteredBy)
$("#filter_infobox").show().html(filteredBy);
else
$("#filter_infobox").hide();
},
Cancel: function() {
$( this ).dialog( "close" );
$("#tree_dbpedia").uncheck_all();
$("#tree_freebase").uncheck_all();
}
}
});
$(".ui-dialog-buttonset button").uniform();
$("#types").click(function(event){
$("#type_selector").dialog("open");
$(".tabs").tabs();
});
$("#spotter").change(function(event){
if(annotated){
runWithSettings();
}
});
$("#bookmarklet_container").hide();
$("#bookmarklet_link").click(function(event) { $("#bookmarklet_container").show().dialog({
dialogClass: 'alert',
width: 700,
height: 200,
modal: true,
position: ['center', 50],
title : "Bookmarklet"
});
});
if (execute) {
runWithSettings();
}
});
function sparqlExample(i) {
switch(i) {
case 1:
s = "SELECT DISTINCT ?politician\nWHERE {\n ?politician a <http://dbpedia.org/ontology/OfficeHolder> .\n ?politician ?related <http://dbpedia.org/resource/Chicago>\n}";
break;
case 2:
s = "PREFIX dbo: <http://dbpedia.org/ontology/>\n\nSELECT ?name ?birth ?death ?person WHERE {\n ?person dbo:birthPlace :Berlin .\n ?person dbo:birthDate ?birth .\n ?person foaf:name ?name .\n ?person dbo:deathDate ?death .\n FILTER (?birth < \"1900-01-01\"^^xsd:date) .\n}\nORDER BY ?name";
break;
case 3:
s = "SELECT ?film\nWHERE { ?film <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:French_films> }";
break;
default:
s = "";
}
$('#sparql_type').val(s);
}
</script>
</head>
<body>
<div class="main">
<img id="logo" height="129" src="dbpedia_spotlight_logo.jpg" />
<div id="action_container" class="container">
<div id="action_options">
<div class="option" style="margin-top: 1em; margin-bottom: 2em;">
<label for="confidence">Confidence:</label><input type="text" id="confidence" name="confidence" value="0.5"/>
<div id="confidence-slider" class="slider"></div>
</div>
<input type="checkbox" id="nbest" /><label for="nbest">n-best candidates</label>
</div>
<div id="action_buttons">
<label for="annotation_language">Language:</label>
<select id="annotation_language" class="action_button">
</select>
<br/>
<!--<select id="disambiguator" class="action_button">
<option value="Default" selected>Default Disambiguation</option>
<option value="Occurrences">Occurrence-centric</option>
<option value="Document">Document-centric</option>
</select>
<br />-->
<br/>
<input class="action_button" id="types" type="button" enabled value="Select types…"/>
<input class="action_button" id="annotate" type="button" enabled value="Annotate"/>
<div id="status_indicator"> </div>
</div>
</div>
<div id="text_container" class="container">
<textarea rows="10" id="text">First documented in the 13th century, Berlin was the capital of the Kingdom of Prussia (1701–1918), the German Empire (1871–1918), the Weimar Republic (1919–33) and the Third Reich (1933–45). Berlin in the 1920s was the third largest municipality in the world. After World War II, the city became divided into East Berlin -- the capital of East Germany -- and West Berlin, a West German exclave surrounded by the Berlin Wall from 1961–89. Following German reunification in 1990, the city regained its status as the capital of Germany, hosting 147 foreign embassies.</textarea>
<div id="edit_text_wrapper">
<input id="edit_text" type="button" value="Back to Text"/>
</div>
</div>
<div id="filter_infobox" class="container" style="display: none;">
</div>
<!--TODO input id="view_source" type="button" value="View Source (RDFa annotations)"/-->
<div id=suggestdialog></div>
<div id="instructions" class="container">
<p style="text-align: center;">This demo uses the statistical DBpedia Spotlight web service at <span id="webservice">http://spotlight.sztaki.hu:2222/rest</span>.</p>
<p style="text-align: center; font-size: 150%; font-weight: bold;"><a href="https://github.com/dbpedia-spotlight/dbpedia-spotlight#citation">How to cite this work</a></p>
<h2>You should know:</h2>
<ul>
<li style="color: black; font-weight: bold;">These demos do not support HTTPS, please switch to the <a href="http://dbpedia-spotlight.github.io/demo/">http version</a> if they don't work in your browser.</li>
<li>This interface has been tested with Firefox 6.0.2 and Chromium 12.0.</li>
<li>We have a cute <a id="bookmarklet_link" href="#bookmarklet_container">bookmarklet</a> that you should try out!</li>
</ul>
</div>
<div id="bookmarklet_container" class="container">
<div>
<br/>
Tired of copying and pasting text here?<br/>
Drag the box "Annotate with DBpedia Spotlight" below to your bookmarks bar (Or right-click and "Bookmark this link").
After doing that, simply select text in any page and click on the bookmark you've just saved to your bookmarks bar.
That will send the text you've selected to DBpedia Spotlight and take you to the annotated text in a blink!
<div class="bookmarklet">
<p>
<a href="javascript:function se(d) {return d.selection ? d.selection.createRange().text : d.getSelection()} s = se(document); for (i=0; i<frames.length && !s; i++) s = se(frames[i].document); if (!s || s=='') s = prompt('Enter%20text%20to%20annotate%20with%20DBpedia%20Spotlight',''); open('http://dbpedia-spotlight.github.com/demo/index.html' + (s ? '?execute=yes&client=bookmarklet&text=' + encodeURIComponent(s) : '')).focus();">
Annotate with DBpedia Spotlight
</a>
</p>
</div>
</div>
</div>
<div id="type_selector">
<div id="filterPolicy">
<input id="filterPolicyWL" type="radio" name="filterPolicy" value="whitelist" checked>Only these types</input>
<input id="filterPolicyBL" type="radio" name="filterPolicy" value="blacklist">None of these types</input>
</div>
<div class="tabs">
<ul>
<li><a href="#tabs-1">DBpedia</a></li>
<li><a href="#tabs-2">Freebase</a></li>
<li><a href="#tabs-3">Schema.org</a></li>
<li><a href="#tabs-4">Custom (SPARQL)</a></li>
</ul>
<div id="tabs-1">
<ul>
<li id="tree_dbpedia" class="tree" />
</ul>
</div>
<div id="tabs-2">
<ul>
<li id="tree_freebase" class="tree" />
</ul>
</div>
<div id="tabs-3">
<ul>
<li id="tree_schema" class="tree" />
</ul>
</div>
<div id="tabs-4">
<textarea id="sparql_type" rows="8"></textarea>
<div id="sparqlExamples">
<strong>Example queries:</strong>
<a href="#" onclick="javascript: sparqlExample(1);">Politicians from Chicago</a>,
<a href="#" onclick="javascript: sparqlExample(2);">People born in Berlin before 1900</a>,
<a href="#" onclick="javascript: sparqlExample(3);">French films</a>.
</div>
</div>
</div>
</div>
</div>
<div class=copyright>This demonstration uses the <a href=http://plugins.jquery.com/project/dbpedia-spotlight>DBpedia Spotlight jQuery Plugin v0.3</a>. <br/> For the latest versions, please visit: <a href=http://spotlight.dbpedia.org>http://spotlight.dbpedia.org</a></div>
<br/>
</body>
</html>