fix stack deploy yml

This commit is contained in:
Patrick Jentsch 2019-11-26 14:58:33 +01:00
parent 7edd635573
commit 5336eac2c9

View File

@ -64,7 +64,19 @@
<div class="card"> <div class="card">
<div class="card-content"> <div class="card-content">
<span class="card-title">Query Results</span> <span class="card-title">Query Results</span>
<div id="query-results"></div> <div>
<table class="highlight">
<thead>
<tr>
<th>Title</th>
<th>Left context</th>
<th>Match</th>
<th>Right Context</th>
</tr>
</thead>
<tbody id="query-results"></tbody>
</table>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -115,56 +127,54 @@
M.toast({html: 'Query has been sent!'}); M.toast({html: 'Query has been sent!'});
}); });
socket.on('corpus_analysis', function(results) { socket.on('corpus_analysis', function(matches) {
if (results === null) { if (matches === null) {
M.toast({html: 'Query has no results!'}); M.toast({html: 'Query has no results!'});
} else { } else {
console.log(results); console.log(matches);
html_txt = '<table class="highlight"> <thead><tr><th>Title</th><th>Left context</th><th>Match</th><th>Right Context</th></tr></thead>'; let htmlString = "";
for (let [key, hit] of Object.entries(results)) { for (let match of Object.values(matches)) {
resultInfo(hit, "word"); niceMatch = matchInfo(match);
var left_context = hit['left_context_cpos'] htmlString += `<tr><td>${niceMatch["text_title"]}</td><td>${niceMatch["left"]}</td><td>${niceMatch["match"]}</td><td>${niceMatch["right"]}</td></tr>`;
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 += '<tr> <td>' + match_source + '</td><td>' + l_text + '</td><td>' + m_text + '</td><td>' + r_text + '</td></tr>';
l_text = '';
m_text = '';
} }
html_txt += '</table>'; queryResultsElement.innerHTML = htmlString;
queryResultsElement.innerHTML = html_txt;
} }
}); });
function resultInfo(result) { function matchInfo(match) {
left = ""; var niceMatch = {"left": "", "match": "", "right": ""};
var tmp = Object.values(Object.values(match["match_cpos"])[0])[0];
for (let entry of result['left_context_cpos']) { niceMatch["text_author"] = tmp["text_author"][1];
let foo = Object.values(entry)[0] niceMatch["text_title"] = tmp["text_title"][1];
left += foo["simple_pos"] === "PUNCT" ? foo["word"] : " " + foo["word"]; 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"] += '<span class="token">'
+ '<span class="word">' + tmp["word"] + '</span>'
+ '<span class="pos">' + tmp["pos"] + '</span>'
+ '<span class="lemma">' + tmp["lemma"] + '</span>'
+ '</span>';
} }
for (let token of Object.values(match['match_cpos'])) {
console.log("Diese andere Info:"); tmp = Object.values(token)[0];
console.log(left); if (tmp["simple_pos"] != "PUNCT") {niceMatch["match"] += " ";}
niceMatch["match"] += '<span class="token" data-cpos="">'
+ '<span class="word">' + tmp["word"] + '</span>'
+ '<span class="pos">' + tmp["pos"] + '</span>'
+ '<span class="lemma">' + tmp["lemma"] + '</span>'
+ '</span>';
} }
for (let token of Object.values(match['right_context_cpos'])) {
function getResultInfos(matchObject, info_key, slice) { tmp = Object.values(token)[0];
var infos = []; if (tmp["simple_pos"] != "PUNCT") {niceMatch["right"] += " ";}
for (let token of Object.values(matchObject)) { niceMatch["right"] += '<span class="token">'
for (let key in token) { + '<span class="word">' + tmp["word"] + '</span>'
infos.push(token[key][info_key]); + '<span class="pos">' + tmp["pos"] + '</span>'
} + '<span class="lemma">' + tmp["lemma"] + '</span>'
} + '</span>';
if (slice) {
console.log(infos);
var infos = infos[slice];
return infos;
} else {
return infos;
} }
return niceMatch
} }
</script> </script>
{% endblock %} {% endblock %}