From e816a2fb15e65a5392ba000f9092f694e6f2ae0f Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Fri, 23 Jun 2023 09:22:34 +0200 Subject: [PATCH] implement missing cqi over socketio functions --- .../cqi_corpora_corpus_subcorpora.py | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/app/corpora/cqi_over_socketio/cqi_corpora_corpus_subcorpora.py b/app/corpora/cqi_over_socketio/cqi_corpora_corpus_subcorpora.py index 38540df7..01c0b048 100644 --- a/app/corpora/cqi_over_socketio/cqi_corpora_corpus_subcorpora.py +++ b/app/corpora/cqi_over_socketio/cqi_corpora_corpus_subcorpora.py @@ -40,22 +40,37 @@ def cqi_corpora_corpus_subcorpora_subcorpus_drop(cqi_client: cqi.CQiClient, corp @socketio.on('cqi.corpora.corpus.subcorpora.subcorpus.dump', namespace=ns) @socketio_login_required @cqi_over_socketio -def cqi_corpora_corpus_subcorpora_subcorpus_dump(cqi_client: cqi.CQiClient): - return {'code': 501, 'msg': 'Not Implemented'} +def cqi_corpora_corpus_subcorpora_subcorpus_dump(cqi_client: cqi.CQiClient, corpus_name: str, subcorpus_name: str, field: int, first: int, last: int): # noqa + cqi_corpus = cqi_client.corpora.get(corpus_name) + cqi_subcorpus = cqi_corpus.subcorpora.get(subcorpus_name) + payload = cqi_subcorpus.dump(field, first, last) + return {'code': 200, 'msg': 'OK', 'payload': payload} @socketio.on('cqi.corpora.corpus.subcorpora.subcorpus.fdist_1', namespace=ns) @socketio_login_required @cqi_over_socketio -def cqi_corpora_corpus_subcorpora_subcorpus_fdist_1(cqi_client: cqi.CQiClient): - return {'code': 501, 'msg': 'Not Implemented'} +def cqi_corpora_corpus_subcorpora_subcorpus_fdist_1(cqi_client: cqi.CQiClient, corpus_name: str, subcorpus_name: str, cutoff: int, field_name: str, positional_attribute_name: str): # noqa + cqi_corpus = cqi_client.corpora.get(corpus_name) + cqi_subcorpus = cqi_corpus.subcorpora.get(subcorpus_name) + field = cqi_subcorpus.fields[field_name] + pos_attr = cqi_corpus.positional_attributes.get(positional_attribute_name) + payload = cqi_subcorpus.fdist_1(cutoff, field, pos_attr) + return {'code': 200, 'msg': 'OK', 'payload': payload} @socketio.on('cqi.corpora.corpus.subcorpora.subcorpus.fdist_2', namespace=ns) @socketio_login_required @cqi_over_socketio -def cqi_corpora_corpus_subcorpora_subcorpus_fdist_2(cqi_client: cqi.CQiClient): - return {'code': 501, 'msg': 'Not Implemented'} +def cqi_corpora_corpus_subcorpora_subcorpus_fdist_2(cqi_client: cqi.CQiClient, corpus_name: str, subcorpus_name: str, cutoff: int, field_1_name: str, positional_attribute_1_name: str, field_2_name: str, positional_attribute_2_name: str): # noqa + cqi_corpus = cqi_client.corpora.get(corpus_name) + cqi_subcorpus = cqi_corpus.subcorpora.get(subcorpus_name) + field_1 = cqi_subcorpus.fields[field_1_name] + pos_attr_1 = cqi_corpus.positional_attributes.get(positional_attribute_1_name) + field_2 = cqi_subcorpus.fields[field_2_name] + pos_attr_2 = cqi_corpus.positional_attributes.get(positional_attribute_2_name) + payload = cqi_subcorpus.fdist_2(cutoff, field_1, pos_attr_1, field_2, pos_attr_2) + return {'code': 200, 'msg': 'OK', 'payload': payload} ###############################################################################