mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
new style
This commit is contained in:
parent
acfcc0321b
commit
e13ed86d29
@ -1,11 +1,11 @@
|
|||||||
from app import db, logger, socketio
|
from app import db, logger, socketio
|
||||||
from app.events import connected_sessions
|
from app.events import connected_sessions
|
||||||
from app.models import Corpus, User
|
from app.models import Corpus, User
|
||||||
# from .cqi import CQiClient
|
from .cqi import CQiClient
|
||||||
from .cqi import CQiWrapper
|
|
||||||
from flask import current_app, request
|
from flask import current_app, request
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
# import math
|
import math
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
' A dictionary containing lists of, with corpus ids associated, Socket.IO
|
' A dictionary containing lists of, with corpus ids associated, Socket.IO
|
||||||
@ -35,11 +35,9 @@ def corpus_analysis_query(query):
|
|||||||
if client is None:
|
if client is None:
|
||||||
socketio.emit('query', '[424]: Failed Dependency', room=request.sid)
|
socketio.emit('query', '[424]: Failed Dependency', room=request.sid)
|
||||||
return
|
return
|
||||||
client.select_corpus('CORPUS')
|
corpus = client.corpora.get('CORPUS')
|
||||||
# corpus = client.corpora.get('CORPUS')
|
|
||||||
try:
|
try:
|
||||||
client.query_subcorpus(query)
|
results = corpus.query(query)
|
||||||
# results = corpus.query(query)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
response = str(e)
|
response = str(e)
|
||||||
@ -47,32 +45,21 @@ def corpus_analysis_query(query):
|
|||||||
response = {'code': 1}
|
response = {'code': 1}
|
||||||
socketio.emit('corpus_analysis_query', response, room=request.sid)
|
socketio.emit('corpus_analysis_query', response, room=request.sid)
|
||||||
else:
|
else:
|
||||||
chunk_size = 100
|
|
||||||
chunk_start = 0
|
|
||||||
context = 100
|
|
||||||
while chunk_start < client.match_count:
|
|
||||||
chunk = client.show_query_results(result_len=chunk_size,
|
|
||||||
context_len=context,
|
|
||||||
result_offset=chunk_start)
|
|
||||||
socketio.emit('corpus_analysis_query', chunk, room=request.sid)
|
|
||||||
chunk_start += chunk_size
|
|
||||||
'''
|
|
||||||
chunk_size = 100
|
chunk_size = 100
|
||||||
chunk_start = 0
|
chunk_start = 0
|
||||||
context = 100
|
context = 100
|
||||||
progress = 0
|
progress = 0
|
||||||
while chunk_start <= results.size:
|
while chunk_start <= results.size:
|
||||||
chunk = results.dump_results(context=context,
|
chunk = results.dump_values(context=context,
|
||||||
first_result=chunk_start,
|
first_result=chunk_start,
|
||||||
num_results=chunk_size)
|
num_results=chunk_size)
|
||||||
progress = ((chunk_start + chunk_size) / results.size) * 100
|
progress = ((chunk_start + chunk_size) / results.size) * 100
|
||||||
progress = min(100, int(math.ceil(progress)))
|
progress = min(100, int(math.ceil(progress)))
|
||||||
socketio.emit('corpus_analysis_query',
|
socketio.emit('corpus_analysis_query',
|
||||||
{'chunk': chunk, 'progress': progress,
|
{'chunk': chunk, 'progress': progress,
|
||||||
'match_count': results.size},
|
'num_matches_total': results.size},
|
||||||
room=request.sid)
|
room=request.sid)
|
||||||
chunk_start += chunk_size
|
chunk_start += chunk_size
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('inspect_match')
|
@socketio.on('inspect_match')
|
||||||
@ -106,8 +93,7 @@ def corpus_analysis_session_handler(app, corpus_id, user_id, session_id):
|
|||||||
while corpus.status != 'analysing':
|
while corpus.status != 'analysing':
|
||||||
db.session.refresh(corpus)
|
db.session.refresh(corpus)
|
||||||
socketio.sleep(3)
|
socketio.sleep(3)
|
||||||
client = CQiWrapper(host='corpus_{}_analysis'.format(corpus_id))
|
client = CQiClient('corpus_{}_analysis'.format(corpus_id))
|
||||||
# client = CQiClient('corpus_{}_analysis'.format(corpus_id))
|
|
||||||
try:
|
try:
|
||||||
client.connect()
|
client.connect()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -77,6 +77,8 @@ function recieveResults(response) {
|
|||||||
let queryStatus;
|
let queryStatus;
|
||||||
queryFinished = false;
|
queryFinished = false;
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
|
||||||
// ERROR code checking
|
// ERROR code checking
|
||||||
if (response["code"] === 0) {
|
if (response["code"] === 0) {
|
||||||
console.log("[SUCCESS] corpus_analysis_init");
|
console.log("[SUCCESS] corpus_analysis_init");
|
||||||
|
Loading…
Reference in New Issue
Block a user