From f84ac489752d306b545d18bf8690100e8a99ae63 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Thu, 22 Jun 2023 14:19:14 +0200
Subject: [PATCH] Add test snippet for fast cpos boundary calculation for
s_attrs
---
.../cqi_over_socketio/cqi_corpora_corpus.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/app/corpora/cqi_over_socketio/cqi_corpora_corpus.py b/app/corpora/cqi_over_socketio/cqi_corpora_corpus.py
index d3503b66..c5125da2 100644
--- a/app/corpora/cqi_over_socketio/cqi_corpora_corpus.py
+++ b/app/corpora/cqi_over_socketio/cqi_corpora_corpus.py
@@ -50,6 +50,21 @@ def cqi_corpora_corpus_update_db(cqi_client: cqi.CQiClient, corpus_name: str):
@cqi_over_socketio
def cqi_corpora_corpus_get_visualization_data(cqi_client: cqi.CQiClient, corpus_name: str):
cqi_corpus = cqi_client.corpora.get(corpus_name)
+ ##########################################################################
+ # A faster way to get cpos boundaries for smaller s_attrs #
+ ##########################################################################
+ # cqi_corpus.query('Last', ' []* ;')
+ # cqi_subcorpus = cqi_corpus.subcorpora.get('Last')
+ # print(cqi_subcorpus.size)
+ # first_match = 0
+ # last_match = cqi_subcorpus.attrs['size'] - 1
+ # match_boundaries = zip(
+ # list(range(first_match, last_match + 1)),
+ # cqi_subcorpus.dump(cqi_subcorpus.attrs['fields']['match'], first_match, last_match),
+ # cqi_subcorpus.dump(cqi_subcorpus.attrs['fields']['matchend'], first_match, last_match)
+ # )
+ # for x in match_boundaries:
+ # print(x)
cqi_p_attrs = {
p_attr.name: p_attr
for p_attr in cqi_corpus.positional_attributes.list()