-
NER auf den digitalen Sammlungen
+ NER - Demo
@@ -35,7 +35,6 @@
-
-
-
+
+
+
+
+
+
diff --git a/qurator/sbb_ner/webapp/static/js/ner-ds-sbb.js b/qurator/sbb_ner/webapp/static/js/ner-ds-sbb.js
new file mode 100644
index 0000000..2dee0dc
--- /dev/null
+++ b/qurator/sbb_ner/webapp/static/js/ner-ds-sbb.js
@@ -0,0 +1,155 @@
+
+$(document).ready(function(){
+
+ $('#nerform').submit(
+ function(e){
+ e.preventDefault();
+ load_ppn();
+ }
+ );
+
+ $.get( "/models")
+ .done(
+ function( data ) {
+ var tmp="";
+ $.each(data,
+ function(index, item){
+
+ selected=""
+ if (item.default) {
+ selected = "selected"
+ }
+
+ tmp += '
'
+ });
+ $('#model').html(tmp);
+ }
+ );
+
+ $.get( "/ppnexamples")
+ .done(
+ function( data ) {
+ var tmp="";
+ $.each(data,
+ function(index, item){
+
+ tmp += '
'
+ });
+ $('#ppnexamples').html(tmp);
+ }
+ );
+
+ task_select()
+});
+
+function task_select() {
+
+ var task = $('#task').val();
+
+ if (task < 3) {
+ $('#model_select').hide()
+ }
+ else {
+ $('#model_select').show()
+ }
+
+ $("#resultregion").html("");
+ $("#legende").html("");
+}
+
+
+function load_ppn() {
+
+ var ppn = $('#ppn').val()
+
+ var text_region_html =
+ `
`;
+
+ var legende_html =
+ `
+
+
`;
+
+ var spinner_html =
+ `
`;
+
+ $("#legende").html("");
+
+ var task = $('#task').val();
+ var model_id = $('#model').val();
+
+ console.log("Task: " + task);
+
+ if (task == 1) {
+ $("#resultregion").html(spinner_html);
+
+ $.get( "/digisam-fulltext/" + ppn)
+ .done(function( data ) {
+ $("#resultregion").html(text_region_html)
+ $("#textregion").html(data.text)
+ })
+ .fail(
+ function() {
+ console.log('Failed.');
+ $("#resultregion").html('Failed.');
+ });
+ }
+ else if (task == 2) {
+ $("#resultregion").html(spinner_html);
+
+ $.get( "/digisam-tokenized/" + ppn,
+ function( data ) {
+ $("#resultregion").html(text_region_html)
+ $("#textregion").html(data.text)
+ }).fail(
+ function() {
+ console.log('Failed.')
+ $("#resultregion").html('Failed.')
+ });
+ }
+ else if (task == 3) {
+
+ $("#resultregion").html(spinner_html);
+
+ $.get( "/digisam-ner/" + model_id + "/" + ppn,
+ function( data ) {
+ $("#resultregion").html(text_region_html)
+ $("#textregion").html(data.text)
+ $("#legende").html(legende_html)
+ }).fail(
+ function(a,b,c) {
+ console.log('Failed.')
+ $("#resultregion").html('Failed.')
+ });
+ }
+ else if (task == 4) {
+ $("#resultregion").html(spinner_html);
+
+ $.get( "/digisam-ner-bert-tokens/" + model_id + "/" + ppn,
+ function( data ) {
+ $("#resultregion").html(text_region_html)
+ $("#textregion").html(data.text)
+ }).fail(
+ function(a,b,c) {
+ console.log('Failed.')
+ $("#resultregion").html('Failed.')
+ });
+ }
+}
\ No newline at end of file
diff --git a/qurator/sbb_ner/webapp/static/js/ner.js b/qurator/sbb_ner/webapp/static/js/ner.js
index 2dee0dc..ed92b69 100644
--- a/qurator/sbb_ner/webapp/static/js/ner.js
+++ b/qurator/sbb_ner/webapp/static/js/ner.js
@@ -4,7 +4,7 @@ $(document).ready(function(){
$('#nerform').submit(
function(e){
e.preventDefault();
- load_ppn();
+ do_task();
}
);
@@ -26,19 +26,6 @@ $(document).ready(function(){
}
);
- $.get( "/ppnexamples")
- .done(
- function( data ) {
- var tmp="";
- $.each(data,
- function(index, item){
-
- tmp += '
'
- });
- $('#ppnexamples').html(tmp);
- }
- );
-
task_select()
});
@@ -58,9 +45,9 @@ function task_select() {
}
-function load_ppn() {
+function do_task() {
- var ppn = $('#ppn').val()
+ var input_text = $('#inputtext').val()
var text_region_html =
`
@@ -95,61 +82,102 @@ function load_ppn() {
var task = $('#task').val();
var model_id = $('#model').val();
- console.log("Task: " + task);
+// if (task == 2) {
+// $("#resultregion").html(spinner_html);
+//
+// $.get( "/digisam-tokenized/" + ppn,
+// function( data ) {
+// $("#resultregion").html(text_region_html)
+// $("#textregion").html(data.text)
+// }).fail(
+// function() {
+// console.log('Failed.')
+// $("#resultregion").html('Failed.')
+// });
+// }
+// else
+//
+ if (task == 3) {
- if (task == 1) {
- $("#resultregion").html(spinner_html);
-
- $.get( "/digisam-fulltext/" + ppn)
- .done(function( data ) {
- $("#resultregion").html(text_region_html)
- $("#textregion").html(data.text)
- })
- .fail(
- function() {
- console.log('Failed.');
- $("#resultregion").html('Failed.');
- });
- }
- else if (task == 2) {
$("#resultregion").html(spinner_html);
- $.get( "/digisam-tokenized/" + ppn,
- function( data ) {
- $("#resultregion").html(text_region_html)
- $("#textregion").html(data.text)
- }).fail(
- function() {
- console.log('Failed.')
- $("#resultregion").html('Failed.')
- });
- }
- else if (task == 3) {
-
- $("#resultregion").html(spinner_html);
-
- $.get( "/digisam-ner/" + model_id + "/" + ppn,
- function( data ) {
- $("#resultregion").html(text_region_html)
- $("#textregion").html(data.text)
- $("#legende").html(legende_html)
- }).fail(
- function(a,b,c) {
- console.log('Failed.')
- $("#resultregion").html('Failed.')
- });
- }
- else if (task == 4) {
- $("#resultregion").html(spinner_html);
-
- $.get( "/digisam-ner-bert-tokens/" + model_id + "/" + ppn,
- function( data ) {
- $("#resultregion").html(text_region_html)
- $("#textregion").html(data.text)
- }).fail(
- function(a,b,c) {
- console.log('Failed.')
- $("#resultregion").html('Failed.')
- });
+ post_data = { "text" : input_text }
+
+ console.log(post_data)
+
+ $.ajax({
+ url: "/ner/" + model_id,
+ data: JSON.stringify(post_data),
+ type: 'POST',
+ contentType: "application/json",
+ success:
+ function( data ) {
+ text_html = ""
+ data.forEach(
+ function(sentence) {
+ sentence.forEach(
+ function(token) {
+
+ if (text_html != "") text_html += ' '
+
+ if (token.prediction == 'O')
+ text_html += token.word
+ else if (token.prediction.endsWith('PER'))
+ text_html += '
' + token.word + ''
+ else if (token.prediction.endsWith('LOC'))
+ text_html += '
' + token.word + ''
+ else if (token.prediction.endsWith('ORG'))
+ text_html += '
' + token.word + ''
+ })
+ text_html += '
'
+ }
+ )
+ $("#resultregion").html(text_region_html)
+ $("#textregion").html(text_html)
+ $("#legende").html(legende_html)
+ }
+ ,
+ error: function(error) {
+ console.log(error);
+ }
+ });
+
+
+// $.post( "/ner/" + model_id, post_data).done(
+// function( data ) {
+//
+// text_region_html = ""
+// data.forEach(
+// function(sentence) {
+// sentence.forEach(
+// function(token) {
+// text_region_html += token.word + "(" + token.prediction + ") "
+// })
+// }
+// )
+//
+// $("#resultregion").html(text_region_html)
+// $("#textregion").html(data.text)
+// $("#legende").html(legende_html)
+// }).fail(
+// function(a,b,c) {
+// console.log('Failed.')
+// $("#resultregion").html('Failed.')
+// });
}
+// else
+//
+// if (task == 4) {
+// $("#resultregion").html(spinner_html);
+//
+// $.get( "/digisam-ner-bert-tokens/" + model_id + "/" + ppn,
+// function( data ) {
+// $("#resultregion").html(text_region_html)
+// $("#textregion").html(data.text)
+// }).fail(
+// function(a,b,c) {
+// console.log('Failed.')
+// $("#resultregion").html('Failed.')
+// });
+// }
}
\ No newline at end of file
diff --git a/qurator/sbb_ner/webapp/static/ner-ds-sbb.html b/qurator/sbb_ner/webapp/static/ner-ds-sbb.html
new file mode 100644
index 0000000..aea93d9
--- /dev/null
+++ b/qurator/sbb_ner/webapp/static/ner-ds-sbb.html
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
NER auf den digitalen Sammlungen
+
+
+
+
+
+
+
+
+
+
+
+
+
NER auf den digitalen Sammlungen
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 42e9ea1..89a5a21 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,6 +4,7 @@ dask
pyarrow
tqdm
pytorch-pretrained-bert==0.6.2
+sklearn
click
langid
seqeval