mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-14 18:10:40 +00:00
Add new way to get results with full contest to provide moreuser feedback
This commit is contained in:
@ -9,6 +9,8 @@ import cqi
|
||||
import math
|
||||
from datetime import datetime
|
||||
|
||||
import time
|
||||
from app import logger
|
||||
|
||||
'''
|
||||
' A dictionary containing lists of, with corpus ids associated, Socket.IO
|
||||
@ -141,9 +143,9 @@ def corpus_analysis_query(query):
|
||||
client.status = 'ready'
|
||||
|
||||
|
||||
@socketio.on('corpus_analysis_inspect_match')
|
||||
@socketio.on('corpus_analysis_get_match_with_full_context')
|
||||
@socketio_login_required
|
||||
def corpus_analysis_inspect_match(payload):
|
||||
def corpus_analysis_get_match_with_full_context(payload):
|
||||
type = payload['type']
|
||||
data_indexes = payload['data_indexes']
|
||||
first_cpos = payload['first_cpos']
|
||||
@ -155,7 +157,7 @@ def corpus_analysis_inspect_match(payload):
|
||||
'msg': 'Failed Dependency',
|
||||
'type': type,
|
||||
'data_indexes': data_indexes}
|
||||
socketio.emit('corpus_analysis_inspect_match', response,
|
||||
socketio.emit('corpus_analysis_get_match_with_full_context', response,
|
||||
room=request.sid)
|
||||
return
|
||||
if client.status == 'running':
|
||||
@ -170,12 +172,29 @@ def corpus_analysis_inspect_match(payload):
|
||||
payload['matches'] = []
|
||||
payload['cpos_lookup'] = {}
|
||||
payload['text_lookup'] = {}
|
||||
payload['cpos_ranges'] = True
|
||||
payload['progress'] = 0
|
||||
i = 0
|
||||
# Send data one match at a time.
|
||||
for index, f_cpos, l_cpos in zip(data_indexes, first_cpos, last_cpos):
|
||||
logger.warning(index)
|
||||
i += 1
|
||||
tmp_match = s.export(f_cpos, l_cpos, context=10)
|
||||
payload['matches'].append(tmp_match['matches'][0])
|
||||
payload['cpos_lookup'].update(tmp_match['cpos_lookup'])
|
||||
payload['text_lookup'].update(tmp_match['text_lookup'])
|
||||
payload['cpos_ranges'] = True
|
||||
payload['progress'] = i/len(data_indexes)*100
|
||||
response = {'code': 200,
|
||||
'desc': None,
|
||||
'msg': 'OK',
|
||||
'payload': payload,
|
||||
'type': type,
|
||||
'data_indexes': data_indexes}
|
||||
socketio.emit('corpus_analysis_get_match_with_full_context',
|
||||
response, room=request.sid)
|
||||
payload['matches'] = []
|
||||
payload['cpos_lookup'] = {}
|
||||
payload['text_lookup'] = {}
|
||||
except cqi.errors.CQiException as e:
|
||||
payload = {'code': e.code, 'desc': e.description, 'msg': e.name}
|
||||
response = {'code': 500,
|
||||
@ -184,14 +203,7 @@ def corpus_analysis_inspect_match(payload):
|
||||
'payload': payload,
|
||||
'type': type,
|
||||
'data_indexes': data_indexes}
|
||||
else:
|
||||
response = {'code': 200,
|
||||
'desc': None,
|
||||
'msg': 'OK',
|
||||
'payload': payload,
|
||||
'type': type,
|
||||
'data_indexes': data_indexes}
|
||||
socketio.emit('corpus_analysis_inspect_match', response, room=request.sid)
|
||||
socketio.emit('corpus_analysis_get_match_with_full_context', response, room=request.sid)
|
||||
client.status = 'ready'
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user