diff --git a/python/philologic/runtime/reports/collocation.py b/python/philologic/runtime/reports/collocation.py
index aaa22168..0abcc0a0 100644
--- a/python/philologic/runtime/reports/collocation.py
+++ b/python/philologic/runtime/reports/collocation.py
@@ -14,7 +14,7 @@
from orjson import dumps
-def collocation_results(request, config):
+def collocation_results(request, config, current_collocates):
"""Fetch collocation results"""
collocation_object: dict[str, Any] = {"query": dict([i for i in request])}
db = DB(config.db_path + "/data/")
@@ -81,7 +81,11 @@ def collocation_results(request, config):
max_time = None
else:
max_time = request.max_time or 2
- all_collocates = {}
+
+ if current_collocates:
+ all_collocates = dict(current_collocates)
+ else:
+ all_collocates = {}
start_time = timeit.default_timer()
env = lmdb.open(
@@ -129,18 +133,17 @@ def collocation_results(request, config):
if collocate is not None: # in the event lemma is None
if collocate_distance is None:
if collocate not in all_collocates:
- all_collocates[collocate] = {"count": 1}
+ all_collocates[collocate] = 1
else:
- all_collocates[collocate]["count"] += 1
+ all_collocates[collocate] += 1
else:
if abs(position - q_word_position[0]) <= collocate_distance: # type: ignore
if collocate not in all_collocates:
- all_collocates[collocate] = {"count": 1}
+ all_collocates[collocate] = 1
else:
- all_collocates[collocate]["count"] += 1
+ all_collocates[collocate] += 1
hits_done += 1
-
elapsed = timeit.default_timer() - start_time
# split the query if more than request.max_time has been spent in the loop
if max_time is not None:
@@ -149,6 +152,7 @@ def collocation_results(request, config):
env.close()
hits.finish()
+ all_collocates = sorted(all_collocates.items(), key=lambda item: item[1], reverse=True)
collocation_object["collocates"] = all_collocates
collocation_object["results_length"] = len(hits)
if hits_done < collocation_object["results_length"]:
@@ -158,10 +162,6 @@ def collocation_results(request, config):
collocation_object["more_results"] = False
collocation_object["hits_done"] = collocation_object["results_length"]
collocation_object["distance"] = collocate_distance
- if len(request.metadata) == 1: # request.metadata always has philo_type as a key
- collocation_object["whole_corpus"] = True
- else:
- collocation_object["whole_corpus"] = False
return collocation_object
diff --git a/www/app/package-lock.json b/www/app/package-lock.json
index 7dcc4f90..8f726671 100644
--- a/www/app/package-lock.json
+++ b/www/app/package-lock.json
@@ -16,6 +16,7 @@
"core-js": "^3.13.1",
"glightbox": "^3.2.0",
"gsap": "^3.9.1",
+ "pako": "^2.1.0",
"vue": "^3.2.0",
"vue-i18n": "^9.2.2",
"vue-router": "^4.0.0",
@@ -2463,6 +2464,11 @@
"node": ">= 0.8.0"
}
},
+ "node_modules/pako": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz",
+ "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug=="
+ },
"node_modules/parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
@@ -4975,6 +4981,11 @@
"word-wrap": "^1.2.3"
}
},
+ "pako": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz",
+ "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug=="
+ },
"parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
diff --git a/www/app/package.json b/www/app/package.json
index bbee5794..a4ee0377 100644
--- a/www/app/package.json
+++ b/www/app/package.json
@@ -53,4 +53,4 @@
"> 1%",
"last 2 versions"
]
-}
\ No newline at end of file
+}
diff --git a/www/app/src/components/Collocation.vue b/www/app/src/components/Collocation.vue
index 452d7d8f..2dbb9bca 100644
--- a/www/app/src/components/Collocation.vue
+++ b/www/app/src/components/Collocation.vue
@@ -9,8 +9,8 @@
@click="getFrequency()">
{{ $t("collocation.collocation") }}
-