From e8fe67d29059e9f2f2b7982d18744b2311c238aa Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Mon, 30 Oct 2023 11:36:28 +0100
Subject: [PATCH] Some code cleanup
---
app/corpora/json_routes.py | 2 +-
.../js/CorpusAnalysis/CorpusAnalysisApp.js | 4 +-
app/static/js/CorpusAnalysis/Utils.js | 53 +++++++++++++++++++
app/static/js/app/index.js | 1 -
app/static/js/cqi/api/client.js | 2 +-
app/static/js/cqi/client.js | 6 +--
app/static/js/cqi/models/attributes.js | 2 +-
app/static/js/{app => nopaque}/app.js | 15 +++---
app/static/js/nopaque/index.js | 1 +
app/templates/_scripts.html.j2 | 6 +--
app/templates/corpora/corpus.html.j2 | 1 -
11 files changed, 71 insertions(+), 22 deletions(-)
create mode 100644 app/static/js/CorpusAnalysis/Utils.js
delete mode 100644 app/static/js/app/index.js
rename app/static/js/{app => nopaque}/app.js (96%)
create mode 100644 app/static/js/nopaque/index.js
diff --git a/app/corpora/json_routes.py b/app/corpora/json_routes.py
index 4fd3a042..79283aaf 100644
--- a/app/corpora/json_routes.py
+++ b/app/corpora/json_routes.py
@@ -61,7 +61,7 @@ def build_corpus(corpus_id):
@bp.route('/stopwords')
@content_negotiation(produces='application/json')
def get_stopwords():
- nltk.download('stopwords')
+ nltk.download('stopwords', quiet=True)
languages = ["german", "english", "catalan", "greek", "spanish", "french", "italian", "russian", "chinese"]
stopwords = {}
for language in languages:
diff --git a/app/static/js/CorpusAnalysis/CorpusAnalysisApp.js b/app/static/js/CorpusAnalysis/CorpusAnalysisApp.js
index c182019b..2bdfac58 100644
--- a/app/static/js/CorpusAnalysis/CorpusAnalysisApp.js
+++ b/app/static/js/CorpusAnalysis/CorpusAnalysisApp.js
@@ -25,12 +25,12 @@ class CorpusAnalysisApp {
async init() {
this.disableActionElements();
this.elements.m.initModal.open();
-
+
try {
// Setup CQi over SocketIO connection and gather data from the CQPServer
const statusTextElement = this.elements.initModal.querySelector('.status-text');
statusTextElement.innerText = 'Creating CQi over SocketIO client...';
- const cqiClient = new cqi.CQiClient('/cqi_over_sio');
+ const cqiClient = new cqi.Client('/cqi_over_sio');
statusTextElement.innerText += ' Done';
statusTextElement.innerHTML = 'Waiting for the CQP server...';
const response = await cqiClient.api.socket.emitWithAck('init', this.corpusId);
diff --git a/app/static/js/CorpusAnalysis/Utils.js b/app/static/js/CorpusAnalysis/Utils.js
new file mode 100644
index 00000000..1ffe1dc0
--- /dev/null
+++ b/app/static/js/CorpusAnalysis/Utils.js
@@ -0,0 +1,53 @@
+ /**
+ * @param {cqi.models.corpora.Corpus} corpus
+ * @param {number[]} cposList
+ * @returns {Promise