From 5336eac2c9ff23e5c1c7b0d4d87478e665317618 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Tue, 26 Nov 2019 14:58:33 +0100
Subject: [PATCH] fix stack deploy yml
---
app/templates/corpora/analyse_corpus.html.j2 | 94 +++++++++++---------
1 file changed, 52 insertions(+), 42 deletions(-)
diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2
index 56504c00..57ce1782 100644
--- a/app/templates/corpora/analyse_corpus.html.j2
+++ b/app/templates/corpora/analyse_corpus.html.j2
@@ -64,7 +64,19 @@
Query Results
-
+
+
+
+
+ Title |
+ Left context |
+ Match |
+ Right Context |
+
+
+
+
+
@@ -115,56 +127,54 @@
M.toast({html: 'Query has been sent!'});
});
- socket.on('corpus_analysis', function(results) {
- if (results === null) {
+ socket.on('corpus_analysis', function(matches) {
+ if (matches === null) {
M.toast({html: 'Query has no results!'});
} else {
- console.log(results);
- html_txt = ' Title | Left context | Match | Right Context |
';
- for (let [key, hit] of Object.entries(results)) {
- resultInfo(hit, "word");
- var left_context = hit['left_context_cpos']
- var match = hit['match_cpos']
- var right_context = hit['right_context_cpos']
- var l_text = getResultInfos(left_context, 'word')
- var m_text = getResultInfos(match, 'word')
- var r_text = getResultInfos(right_context, 'word')
- var match_source = getResultInfos(match, 'text_title', 1)
- html_txt += ' ' + match_source + ' | ' + l_text + ' | ' + m_text + ' | ' + r_text + ' |
';
- l_text = '';
- m_text = '';
+ console.log(matches);
+ let htmlString = "";
+ for (let match of Object.values(matches)) {
+ niceMatch = matchInfo(match);
+ htmlString += `${niceMatch["text_title"]} | ${niceMatch["left"]} | ${niceMatch["match"]} | ${niceMatch["right"]} |
`;
}
- html_txt += '
';
- queryResultsElement.innerHTML = html_txt;
+ queryResultsElement.innerHTML = htmlString;
}
});
- function resultInfo(result) {
- left = "";
-
- for (let entry of result['left_context_cpos']) {
- let foo = Object.values(entry)[0]
- left += foo["simple_pos"] === "PUNCT" ? foo["word"] : " " + foo["word"];
+ function matchInfo(match) {
+ var niceMatch = {"left": "", "match": "", "right": ""};
+ var tmp = Object.values(Object.values(match["match_cpos"])[0])[0];
+ niceMatch["text_author"] = tmp["text_author"][1];
+ niceMatch["text_title"] = tmp["text_title"][1];
+ niceMatch["publishing_year"] = tmp["text_publishing_year"][1];
+ for (let token of Object.values(match['left_context_cpos'])) {
+ tmp = Object.values(token)[0];
+ if (tmp["simple_pos"] != "PUNCT") {niceMatch["left"] += " ";}
+ niceMatch["left"] += ''
+ + '' + tmp["word"] + ''
+ + '' + tmp["pos"] + ''
+ + '' + tmp["lemma"] + ''
+ + '';
}
-
- console.log("Diese andere Info:");
- console.log(left);
- }
-
- function getResultInfos(matchObject, info_key, slice) {
- var infos = [];
- for (let token of Object.values(matchObject)) {
- for (let key in token) {
- infos.push(token[key][info_key]);
- }
+ for (let token of Object.values(match['match_cpos'])) {
+ tmp = Object.values(token)[0];
+ if (tmp["simple_pos"] != "PUNCT") {niceMatch["match"] += " ";}
+ niceMatch["match"] += ''
+ + '' + tmp["word"] + ''
+ + '' + tmp["pos"] + ''
+ + '' + tmp["lemma"] + ''
+ + '';
}
- if (slice) {
- console.log(infos);
- var infos = infos[slice];
- return infos;
- } else {
- return infos;
+ for (let token of Object.values(match['right_context_cpos'])) {
+ tmp = Object.values(token)[0];
+ if (tmp["simple_pos"] != "PUNCT") {niceMatch["right"] += " ";}
+ niceMatch["right"] += ''
+ + '' + tmp["word"] + ''
+ + '' + tmp["pos"] + ''
+ + '' + tmp["lemma"] + ''
+ + '';
}
+ return niceMatch
}
{% endblock %}