mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
First output of query results
This commit is contained in:
parent
28171eb525
commit
1152417419
@ -43,13 +43,13 @@ def recv_query(message):
|
|||||||
analysis_client = analysis_clients[request.sid]
|
analysis_client = analysis_clients[request.sid]
|
||||||
""" Prepare and execute a query """
|
""" Prepare and execute a query """
|
||||||
corpus = 'CORPUS'
|
corpus = 'CORPUS'
|
||||||
query = '"and";'
|
query = message['query']
|
||||||
query_subcorpus = 'Results'
|
query_subcorpus = 'Results'
|
||||||
analysis_client.cqp_query(corpus, query_subcorpus, query)
|
analysis_client.cqp_query(corpus, query_subcorpus, query)
|
||||||
""" Evaluate query results """
|
""" Evaluate query results """
|
||||||
match_corpus = '{}:{}'.format(corpus, query_subcorpus)
|
match_corpus = '{}:{}'.format(corpus, query_subcorpus)
|
||||||
match_num = analysis_client.cqp_subcorpus_size(match_corpus)
|
match_num = analysis_client.cqp_subcorpus_size(match_corpus)
|
||||||
match_num = min(19, match_num)
|
match_num = min(int(message['hits_per_page']) - 1, match_num)
|
||||||
if match_num == 0:
|
if match_num == 0:
|
||||||
print('No matches found.')
|
print('No matches found.')
|
||||||
exit()
|
exit()
|
||||||
@ -67,6 +67,7 @@ def recv_query(message):
|
|||||||
pos = analysis_client.cl_cpos2str('{}.pos'.format(corpus), range(match_start, match_end + 1))
|
pos = analysis_client.cl_cpos2str('{}.pos'.format(corpus), range(match_start, match_end + 1))
|
||||||
matches.append({'tokens': tokens, 'pos': pos})
|
matches.append({'tokens': tokens, 'pos': pos})
|
||||||
logger.warning(matches)
|
logger.warning(matches)
|
||||||
|
socketio.emit('query_results', matches, room=request.sid)
|
||||||
|
|
||||||
|
|
||||||
def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
||||||
|
@ -76,18 +76,17 @@
|
|||||||
socket.on('query_results', function(json_results) {
|
socket.on('query_results', function(json_results) {
|
||||||
console.log('Results recieved')
|
console.log('Results recieved')
|
||||||
console.log(json_results)
|
console.log(json_results)
|
||||||
let json_results = json_results;
|
var queryResultsElement = document.getElementById("query-results");
|
||||||
|
for (let json_result of json_results) {
|
||||||
|
queryResultsElement.innerHTML += json_result['tokens'] + '<br>';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<div class="col s12 m9 l9">
|
<div class="col s12 m9 l9">
|
||||||
<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>
|
||||||
<table class="responsive highlight">
|
<p id="query-results"></p>
|
||||||
{% for hit in json_results %}
|
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user