This commit is contained in:
Patrick Jentsch 2020-03-29 20:54:51 +02:00
parent 4ff372de77
commit 6e3579b33f
9 changed files with 19 additions and 11 deletions

View File

@ -1,5 +1,5 @@
from time import sleep
from .. import specification
from . import specification
from ..errors import cl_error_lookup, error_lookup, cqp_error_lookup
import socket
import struct

View File

@ -1,4 +1,4 @@
from . import specification
from .api import specification
class CQiException(Exception):

View File

@ -64,5 +64,4 @@ class Corpus:
return lookups
def query(self, query, subcorpus_name='Results'):
self.client.api.cqp_query(self.name, subcorpus_name, query)
return self.subcorpora.get('Results')
return self.client.api.cqp_query(self.name, subcorpus_name, query)

View File

@ -1,4 +1,4 @@
from ..specification import (CONST_FIELD_KEYWORD, CONST_FIELD_MATCH,
from ..api.specification import (CONST_FIELD_KEYWORD, CONST_FIELD_MATCH,
CONST_FIELD_MATCHEND, CONST_FIELD_TARGET)

View File

@ -1,4 +1,4 @@
from .specification import MAJOR_VERSION, MINOR_VERSION
from .api.specification import MAJOR_VERSION, MINOR_VERSION
version = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)

View File

@ -1,5 +1,5 @@
from .api import APIClient
from .specification import CONST_FIELD_MATCH, CONST_FIELD_MATCHEND
from .api.specification import CONST_FIELD_MATCH, CONST_FIELD_MATCHEND
import time

View File

@ -52,7 +52,7 @@ def corpus_analysis_query(query):
return
corpus = client.corpora.get('CORPUS')
try:
results = corpus.query(query)
corpus.query(query)
except Exception as e:
logger.warning(e)
response = str(e)
@ -60,6 +60,7 @@ def corpus_analysis_query(query):
response = {'code': 1}
socketio.emit('corpus_analysis_query', response, room=request.sid)
else:
results = corpus.subcorpora.get('Results')
chunk_size = 100
chunk_start = 0
context = 100

View File

@ -47,7 +47,15 @@ def pj_corpus_analysis_query(query):
socketio.emit('pj_corpus_analysis_query', response, room=request.sid)
return
try:
results = corpus.query(query)
query_status = corpus.query(query)
except cqi.errors.CQiException as e:
response = {'code': 500, 'desc': None, 'msg': 'Internal Server Error',
'payload': {'code': e.code, 'desc': e.description,
'msg': e.name}}
socketio.emit('pj_corpus_analysis_query', response, room=request.sid)
return
try:
results = corpus.subcorpora.get('Results')
except cqi.errors.CQiException as e:
response = {'code': 500, 'desc': None, 'msg': 'Internal Server Error',
'payload': {'code': e.code, 'desc': e.description,
@ -55,7 +63,7 @@ def pj_corpus_analysis_query(query):
socketio.emit('pj_corpus_analysis_query', response, room=request.sid)
return
response = {'code': 200, 'desc': None, 'msg': 'OK',
'payload': {'num_matches': results.size}}
'payload': {**query_status, 'num_matches': results.size}}
socketio.emit('pj_corpus_analysis_query', response, room=request.sid)
chunk_size = 100
chunk_start = 0