mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
This commit is contained in:
commit
b5afdf74f2
@ -23,7 +23,7 @@ def create_app(config_name):
|
||||
db.init_app(app)
|
||||
login_manager.init_app(app)
|
||||
mail.init_app(app)
|
||||
socketio.init_app(app, message_qeue='redis://redis:6379')
|
||||
socketio.init_app(app, message_queue='redis://redis:6379')
|
||||
|
||||
from . import events
|
||||
|
||||
|
@ -64,7 +64,19 @@
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<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>
|
||||
@ -91,80 +103,60 @@
|
||||
<script>
|
||||
var loadingModal;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
loadingModal = M.Modal.init(document.getElementById("loading-modal"),
|
||||
{"dismissible": false});
|
||||
loadingModal.open();
|
||||
socket.emit("request_corpus_analysis", {{ corpus_id }});
|
||||
});
|
||||
socket.emit('request_corpus_analysis', {{ corpus_id }});
|
||||
socket.on('request_corpus_analysis', function(msg) {
|
||||
if (msg === '[201]: Created') {loadingModal.close();}
|
||||
|
||||
socket.on("request_corpus_analysis", function(msg) {
|
||||
if (msg === "[201]: Created") {loadingModal.close();}
|
||||
});
|
||||
|
||||
var queryFormElement = document.getElementById("query-form");
|
||||
var queryFormSubmitElement = document.getElementById("query-form-submit");
|
||||
var queryResultsElement = document.getElementById("query-results");
|
||||
|
||||
queryFormSubmitElement.addEventListener('click', function(event) {
|
||||
queryFormSubmitElement.addEventListener("click", function(event) {
|
||||
event.preventDefault();
|
||||
let formData = new FormData(queryFormElement);
|
||||
let queryData = {'context': formData.get('context'),
|
||||
'hits_per_page': formData.get('hits_per_page'),
|
||||
'query': formData.get('query')};
|
||||
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.on('corpus_analysis', function(results) {
|
||||
if (results === null) {
|
||||
M.toast({html: 'Query has no results!'});
|
||||
} else {
|
||||
console.log(results);
|
||||
html_txt = '<table class="highlight"> <thead><tr><th>Title</th><th>Left context</th><th>Match</th><th>Right Context</th></tr></thead>';
|
||||
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 += '<tr> <td>' + match_source + '</td><td>' + l_text + '</td><td>' + m_text + '</td><td>' + r_text + '</td></tr>';
|
||||
l_text = '';
|
||||
m_text = '';
|
||||
socket.on('corpus_analysis', function(result) {
|
||||
console.log(result['matches']);
|
||||
|
||||
var htmlString;
|
||||
var token;
|
||||
|
||||
for (let match of result['matches']) {
|
||||
htmlString = `<tr class="match">`;
|
||||
htmlString += `<td class="left-context">`;
|
||||
for (cpos of match['lc']) {
|
||||
token = result['cpos_lookup'][cpos];
|
||||
htmlString += `<span data-cpos="${cpos}">${token['word']}</span>`;
|
||||
}
|
||||
html_txt += '</table>';
|
||||
queryResultsElement.innerHTML = html_txt;
|
||||
htmlString += `</td>`;
|
||||
htmlString += `<td class="hit">`;
|
||||
for (cpos of match["hit"]) {
|
||||
token = result['cpos_lookup'][cpos];
|
||||
htmlString += `<span 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>`;
|
||||
}
|
||||
htmlString += `</td>`;
|
||||
htmlString += `</tr>`;
|
||||
queryResultsElement.insertAdjacentHTML("beforeend", 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"];
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
if (slice) {
|
||||
console.log(infos);
|
||||
var infos = infos[slice];
|
||||
return infos;
|
||||
} else {
|
||||
return infos;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@ -2,9 +2,6 @@ version: '3'
|
||||
|
||||
services:
|
||||
web:
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
@ -17,9 +14,8 @@ services:
|
||||
- 5000:5000
|
||||
volumes:
|
||||
- storage:/mnt/opaque
|
||||
- ./logs:/home/opaque/logs
|
||||
daemon:
|
||||
depends_on:
|
||||
- db
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
@ -30,6 +26,7 @@ services:
|
||||
image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque_daemon:latest
|
||||
volumes:
|
||||
- storage:/mnt/opaque
|
||||
- ./logs:/home/opaque_daemon/logs
|
||||
- $HOME/.docker/config.json:/home/opaque_daemon/.docker/config.json
|
||||
db:
|
||||
deploy:
|
||||
|
Loading…
Reference in New Issue
Block a user