mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-12 09:00:40 +00:00
push
This commit is contained in:
@ -42,6 +42,7 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<span class="card-title">Query Link</span>
|
||||
<form id="download-form" method="POST">
|
||||
{{ query_download_form.hidden_tag() }}
|
||||
<span class="card-title">Download Results</span>
|
||||
@ -124,39 +125,55 @@
|
||||
let queryData = {"context": formData.get("context"),
|
||||
"hits_per_page": formData.get("hits_per_page"),
|
||||
"query": formData.get("query")};
|
||||
socket.emit('corpus_analysis', queryData);
|
||||
M.toast({html: 'Query has been sent!'});
|
||||
socket.emit("corpus_analysis", queryData);
|
||||
M.toast({html: "Query has been sent!"});
|
||||
});
|
||||
|
||||
socket.on('corpus_analysis', function(result) {
|
||||
console.log(result['matches']);
|
||||
|
||||
var htmlString;
|
||||
socket.on("corpus_analysis", function(result) {
|
||||
console.log(result);
|
||||
var htmlString = "";
|
||||
var token;
|
||||
|
||||
if (result['matches'].length === 0) {
|
||||
M.toast({html: 'No results!'});
|
||||
}
|
||||
|
||||
for (let match of result['matches']) {
|
||||
htmlString = `<tr class="match">`;
|
||||
htmlString += `<tr class="match">`;
|
||||
htmlString += `<td class="title"></td>`
|
||||
htmlString += `<td class="left-context">`;
|
||||
for (cpos of match['lc']) {
|
||||
token = result['cpos_lookup'][cpos];
|
||||
htmlString += `<span data-cpos="${cpos}">${token['word']}</span>`;
|
||||
for (cpos of match["lc"]) {
|
||||
token = result["cpos_lookup"][cpos];
|
||||
htmlString += token["simple_pos"] != "PUNCT" ? " " : "";
|
||||
htmlString += `<span class="token" data-cpos="${cpos}">${token["word"]}</span>`;
|
||||
}
|
||||
htmlString += `</td>`;
|
||||
htmlString += `<td class="hit">`;
|
||||
for (cpos of match["hit"]) {
|
||||
token = result['cpos_lookup'][cpos];
|
||||
htmlString += `<span data-cpos="${cpos}">${token['word']}</span>`;
|
||||
token = result["cpos_lookup"][cpos];
|
||||
htmlString += token["simple_pos"] != "PUNCT" ? " " : "";
|
||||
htmlString += `<span class="token" data-cpos="${cpos}">${token["word"]}</span>`;
|
||||
}
|
||||
htmlString += `</td>`;
|
||||
htmlString += `<td class="right-context">`;
|
||||
for (cpos of match['rc']) {
|
||||
token = result['cpos_lookup'][cpos];
|
||||
htmlString += `<span data-cpos="${cpos}">${token['word']}</span>`;
|
||||
for (cpos of match["rc"]) {
|
||||
token = result["cpos_lookup"][cpos];
|
||||
htmlString += token["simple_pos"] != "PUNCT" ? " " : "";
|
||||
htmlString += `<span class="token" data-cpos="${cpos}">${token["word"]}</span>`;
|
||||
}
|
||||
htmlString += `</td>`;
|
||||
htmlString += `</tr>`;
|
||||
queryResultsElement.insertAdjacentHTML("beforeend", htmlString);
|
||||
}
|
||||
|
||||
queryResultsElement.innerHTML = htmlString;
|
||||
|
||||
queryResultsElement.querySelectorAll(".token").forEach(function(tokenElement) {
|
||||
tokenElement.addEventListener("click", function(event) {
|
||||
let token = result["cpos_lookup"][tokenElement.dataset.cpos];
|
||||
let text = result["text_loopup"][token["text_id"]];
|
||||
alert(`${token["word"]} // ${token["pos"]} // ${token["simple_pos"]} // ${text["title"]}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user