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
a4ffee5b2e
@ -294,4 +294,7 @@ class CQiWrapper(CQiClient):
|
|||||||
t1 = time.time()
|
t1 = time.time()
|
||||||
t_total = t1 - t0
|
t_total = t1 - t0
|
||||||
logger.warning('Got all sentences informations in {} seconds'. format(t_total))
|
logger.warning('Got all sentences informations in {} seconds'. format(t_total))
|
||||||
return context_sentences, all_cpos_infos, text_lookup
|
match_context = {'context_s_cpos': context_sentences,
|
||||||
|
'cpos_lookup': all_cpos_infos,
|
||||||
|
'text_lookup': text_lookup}
|
||||||
|
return match_context
|
||||||
|
@ -42,7 +42,7 @@ def corpus_analysis(message):
|
|||||||
socketio.emit('query', '[424]: Failed Dependency',
|
socketio.emit('query', '[424]: Failed Dependency',
|
||||||
room=request.sid)
|
room=request.sid)
|
||||||
return
|
return
|
||||||
""" Prepare and execute a query """
|
# Prepare and execute a query
|
||||||
corpus_name = 'CORPUS'
|
corpus_name = 'CORPUS'
|
||||||
query = str(message['query'])
|
query = str(message['query'])
|
||||||
result_len = int(message['hits_per_page'])
|
result_len = int(message['hits_per_page'])
|
||||||
@ -57,6 +57,21 @@ def corpus_analysis(message):
|
|||||||
socketio.emit('corpus_analysis', results, room=request.sid)
|
socketio.emit('corpus_analysis', results, room=request.sid)
|
||||||
|
|
||||||
|
|
||||||
|
@socketio.on('inspect_match')
|
||||||
|
@login_required
|
||||||
|
def inspect_match(message):
|
||||||
|
client = corpus_analysis_clients.get(request.sid)
|
||||||
|
if client is None:
|
||||||
|
socketio.emit('query', '[424]: Failed Dependency',
|
||||||
|
room=request.sid)
|
||||||
|
return
|
||||||
|
# Get more context for given match CPOS
|
||||||
|
match_context = client.get_sentences(message['cpos'],
|
||||||
|
get_surrounding_s=True,
|
||||||
|
l_r_s_context_additional_len=3)
|
||||||
|
socketio.emit('match_context', match_context, room=request.sid)
|
||||||
|
|
||||||
|
|
||||||
def corpus_analysis_session_handler(app, corpus_id, session_id):
|
def corpus_analysis_session_handler(app, corpus_id, session_id):
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
''' Setup analysis session '''
|
''' Setup analysis session '''
|
||||||
|
@ -137,6 +137,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="context-modal" class="modal">
|
||||||
|
<div class="modal-content">
|
||||||
|
<h4>Modal Header</h4>
|
||||||
|
<p>A bunch of text</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Agree</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var loadingModal;
|
var loadingModal;
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
@ -196,9 +206,10 @@
|
|||||||
|
|
||||||
queryResultsElement.innerHTML = "";
|
queryResultsElement.innerHTML = "";
|
||||||
|
|
||||||
for (let match of result['matches']) {
|
for (let [index, match] of result['matches'].entries()) {
|
||||||
matchElement = document.createElement("tr");
|
matchElement = document.createElement("tr");
|
||||||
matchElement.classList.add("match");
|
matchElement.classList.add("match");
|
||||||
|
matchElement.dataset.index = index;
|
||||||
matchTextTitlesElement = document.createElement("td");
|
matchTextTitlesElement = document.createElement("td");
|
||||||
matchTextTitlesElement.classList.add("text-titles");
|
matchTextTitlesElement.classList.add("text-titles");
|
||||||
matchElement.append(matchTextTitlesElement);
|
matchElement.append(matchTextTitlesElement);
|
||||||
@ -237,6 +248,16 @@
|
|||||||
tokenElements.push(tokenElement);
|
tokenElements.push(tokenElement);
|
||||||
textTitles.add(result["text_lookup"][token["text"]]["title"]);
|
textTitles.add(result["text_lookup"][token["text"]]["title"]);
|
||||||
}
|
}
|
||||||
|
var moreContextBtn = document.createElement("a");
|
||||||
|
moreContextBtn.setAttribute("class", "btn-floating btn waves-effect waves-light teal right");
|
||||||
|
moreContextBtn.innerHTML = '<i class="material-icons">search</i>';
|
||||||
|
matchHitElement.append(document.createElement("br"), document.createElement("br"));
|
||||||
|
matchHitElement.append(moreContextBtn);
|
||||||
|
moreContextBtn.onclick = function(){
|
||||||
|
var cpos = match["hit"];
|
||||||
|
socket.emit("inspect_match", {"cpos": cpos});
|
||||||
|
};
|
||||||
|
|
||||||
matchTextTitlesElement.innerText = [...textTitles].join(",");
|
matchTextTitlesElement.innerText = [...textTitles].join(",");
|
||||||
matchElement.append(matchHitElement);
|
matchElement.append(matchHitElement);
|
||||||
matchRightContextElement = document.createElement("td");
|
matchRightContextElement = document.createElement("td");
|
||||||
@ -277,15 +298,22 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="left-align">
|
<td class="left-align">
|
||||||
Title: ${result["text_lookup"][token["text"]]["title"]}<br>
|
Title: ${result["text_lookup"][token["text"]]["title"]}<br>
|
||||||
Author: ${result["text_lookup"][token["text"]]["title"]}<br>
|
Author: ${result["text_lookup"][token["text"]]["author"]}<br>
|
||||||
Publishing year: ${result["text_lookup"][token["text"]]["publishing_year"]}
|
Publishing year: ${result["text_lookup"][token["text"]]["publishing_year"]}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>`,
|
</table>`,
|
||||||
"inDuration": 2500,
|
"inDuration": 1500,
|
||||||
"margin": 15,
|
"margin": 15,
|
||||||
"position": "top",
|
"position": "top",
|
||||||
"transitionMovement": 0});
|
"transitionMovement": 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
socket.on("match_context", function(message) {
|
||||||
|
console.log(message);
|
||||||
|
var elems = document.querySelectorAll('.modal');
|
||||||
|
var instances = M.Modal.init(elems);
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user