Merge branch 'query-builder' of gitlab.ub.uni-bielefeld.de:sfb1288inf/nopaque into query-builder

This commit is contained in:
Inga Kirschnick 2023-11-07 13:24:11 +01:00
commit 1f40002249
11 changed files with 71 additions and 22 deletions

View File

@ -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:

View File

@ -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);

View File

@ -0,0 +1,53 @@
/**
* @param {cqi.models.corpora.Corpus} corpus
* @param {number[]} cposList
* @returns {Promise<object>}
*/
async function lookupsByCpos(corpus, cposList) {
let lookups = {};
lookups['cpos_lookup'] = {};
for (let cpos in cposList) {
lookups['cpos_lookup'][cpos] = {};
}
let pAttrs = await corpus.positionalAttributes.list();
for (let attr in pAttrs) {
let values = await attr.valuesByCpos(cposList);
for (let i = 0; i < cposList.length; i++) {
let cpos = cposList[i];
let value = values[i];
lookups['cpos_lookup'][cpos][attr.name] = value;
}
}
let sAttrs = await corpus.structuralAttributes.list();
for (let attr in sAttrs) {
// We only want to iterate over non subattributes, identifiable by
// sAttr.hasValues == false
if (attr.hasValues) {continue;}
let idList = await attr.idsByCpos(cposList);
for (let i = 0; i < cposList.length; i++) {
let cpos = cposList[i];
let id = idList[i];
if (id == -1) {continue;}
lookups['cpos_lookup'][cpos][attr.name] = id;
}
let occuredIdList = Array.from(new Set(idList.filter(x => x != -1)));
if (occuredIdList.length == 0) {continue;}
let subattrs = sAttrs.filter(x => x.name.startsWith(`${attr.name}_`));
if (subattrs.length == 0) {continue;}
let lookupName = `${attr.name}_lookup`;
lookups[lookupName] = {};
for (let id in occuredIdList) {
lookups[lookupName][id] = {};
}
}
return lookups;
}

View File

@ -1 +0,0 @@
App = {};

View File

@ -1,4 +1,4 @@
cqi.api.APIClient = class APIClient {
cqi.api.Client = class Client {
/**
* @param {string} host
* @param {number} [timeout=60] timeout

View File

@ -1,12 +1,12 @@
cqi.CQiClient = class CQiClient {
cqi.Client = class Client {
/**
* @param {string} host
* @param {number} [timeout=60] timeout
* @param {string} [version=0.1] version
*/
constructor(host, timeout = 60, version = '0.1') {
/** @type {cqi.api.APIClient} */
this.api = new cqi.api.APIClient(host, timeout, version);
/** @type {cqi.api.Client} */
this.api = new cqi.api.Client(host, timeout, version);
}
/**

View File

@ -37,7 +37,7 @@ cqi.models.attributes.AttributeCollection = class AttributeCollection extends cq
static model = cqi.models.attributes.Attribute;
/**
* @param {cqi.CQiClient} client
* @param {cqi.Client} client
* @param {cqi.models.corpora.Corpus} corpus
*/
constructor(client, corpus) {

View File

@ -1,9 +1,4 @@
// IDEA: Split the App logic into seperate units
// - App.Data
// - App.IO (name is WIP)
// - App.UI
App.App = class App {
nopaque.App = class App {
constructor() {
this.data = {
promises: {getUser: {}, subscribeUser: {}},
@ -139,9 +134,9 @@ App.App = class App {
}
optgroupElement.remove();
}
// #endregion
/* Initialize Materialize Components */
// #region
@ -190,10 +185,12 @@ App.App = class App {
);
// #endregion
// #region Nopaque Components
/* Initialize nopaque Components */
// #region
ResourceDisplays.AutoInit();
ResourceLists.AutoInit();
Forms.AutoInit();
// #endregion Nopaque Components
// #endregion
}
};

View File

@ -0,0 +1 @@
var nopaque = {};

View File

@ -7,8 +7,8 @@
{%- assets
filters='rjsmin',
output='gen/app.%(version)s.js',
'js/app/index.js',
'js/app/app.js'
'js/nopaque/index.js',
'js/nopaque/app.js'
%}
<script src="{{ ASSET_URL }}"></script>
{%- endassets %}
@ -115,7 +115,7 @@
<script>
// TODO: Implement an app.run method and use this for all of the following
const app = new App.App();
const app = new nopaque.App();
app.init();
// Check if the current user is authenticated

View File

@ -281,7 +281,6 @@ let users = {
{% if not loop.last %},{% endif %}
{% endfor %}
};
console.log(users);
let inviteUserModalSearch = M.Chips.init(
inviteUserModalSearchElement,