mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-04-05 00:34:24 +00:00
Add metadata object on analysis
This commit is contained in:
parent
a17771a772
commit
1350e6ddd6
@ -8,6 +8,7 @@ from ..models import Corpus, User
|
|||||||
import cqi
|
import cqi
|
||||||
import math
|
import math
|
||||||
from app import logger
|
from app import logger
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -47,16 +48,18 @@ def corpus_analysis_get_meta_data(corpus_id):
|
|||||||
metadata['corpus_properties'] = client_corpus.attrs['properties']
|
metadata['corpus_properties'] = client_corpus.attrs['properties']
|
||||||
metadata['corpus_size_tokens'] = client_corpus.attrs['size']
|
metadata['corpus_size_tokens'] = client_corpus.attrs['size']
|
||||||
|
|
||||||
texts = {}
|
|
||||||
text_attr = client_corpus.structural_attributes.get('text')
|
text_attr = client_corpus.structural_attributes.get('text')
|
||||||
for text_id in range(0, (text_attr.attrs['size'])):
|
struct_attrs = client_corpus.structural_attributes.list(filters={'part_of': text_attr})
|
||||||
texts[text_id] = {}
|
text_ids = range(0, (text_attr.attrs['size']))
|
||||||
logger.warning('Text ID: {}'.format(text_id))
|
texts_metadata = {}
|
||||||
struct_attrs = client_corpus.structural_attributes.list(filters={'part_of': text_attr})
|
for text_id in text_ids:
|
||||||
|
texts_metadata[text_id] = {}
|
||||||
for struct_attr in struct_attrs:
|
for struct_attr in struct_attrs:
|
||||||
logger.warning(struct_attr)
|
texts_metadata[text_id][struct_attr.attrs['name'][(len(text_attr.attrs['name']) + 1):]] = struct_attr.values_by_ids(list(range(struct_attr.attrs['size'])))[text_id]
|
||||||
for struct_id in list(range(0, struct_attr.attrs['size'])):
|
metadata['corpus_all_texts'] = texts_metadata
|
||||||
logger.warning(struct_attr.values_by_ids([struct_id]))
|
metadata['corpus_analysis_date'] = datetime.utcnow().isoformat()
|
||||||
|
metadata['corpus_cqi_py_version'] = cqi.version
|
||||||
|
metadata['corpus_cqpserver_version'] = 'CQPserver v3.4.22' # TODO: make this dynamically
|
||||||
|
|
||||||
payload = metadata
|
payload = metadata
|
||||||
response = {'code': 200, 'desc': 'Corpus meta data', 'msg': 'OK', 'payload': payload}
|
response = {'code': 200, 'desc': 'Corpus meta data', 'msg': 'OK', 'payload': payload}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
class Results {
|
class Results {
|
||||||
constructor(resultsJSON, resultsList , metaDataJSON) {
|
constructor(resultsJSON, resultsList , resultsMetaData) {
|
||||||
this.resultsJSON = resultsJSON;
|
this.resultsJSON = resultsJSON;
|
||||||
this.resultsList = resultsList;
|
this.resultsList = resultsList;
|
||||||
this.metaDataJSON = metaDataJSON
|
this.resultsMetaData = resultsMetaData
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAll() {
|
clearAll() {
|
||||||
this.resultsList.clear();
|
this.resultsList.clear();
|
||||||
this.resultsList.update();
|
this.resultsList.update();
|
||||||
this.resultsJSON.init();
|
this.resultsJSON.init();
|
||||||
this.metaDataJSON.init();
|
this.resultsMetaData.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,14 +77,10 @@ class ResultsJSON {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MetaDataJSON {
|
class ResultsMetaData {
|
||||||
// Sets empty object structure. Also usefull to delete old results.
|
// Sets empty object structure when no input is given.
|
||||||
init() {
|
// Else it works like a delete.
|
||||||
this["corpus_name"] = undefined;
|
init(json = {}) {
|
||||||
this["corpus_description"] = undefined;
|
Object.assign(this, json);
|
||||||
this["corpus_creation_date"] = undefined;
|
|
||||||
this["corpus_last_edited_date"] = undefined;
|
|
||||||
this["corpus_properties"] = undefined;
|
|
||||||
this["corpus_size_tokens"] = undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,16 @@
|
|||||||
function recvMetaData(payload) {
|
function recvMetaData(payload) {
|
||||||
results.metaDataJSON.corpus_name = payload.corpus_name;
|
results.resultsMetaData.init(payload)
|
||||||
results.metaDataJSON.corpus_description = payload.corpus_description;
|
// results.metaDataJSON.corpus_name = payload.corpus_name;
|
||||||
results.metaDataJSON.corpus_creation_date = payload.corpus_creation_date;
|
// results.metaDataJSON.corpus_description = payload.corpus_description;
|
||||||
results.metaDataJSON.corpus_last_edited_date = payload.corpus_last_edited_date;
|
// results.metaDataJSON.corpus_creation_date = payload.corpus_creation_date;
|
||||||
results.metaDataJSON.corpus_properties = payload.corpus_properties;
|
// results.metaDataJSON.corpus_last_edited_date = payload.corpus_last_edited_date;
|
||||||
results.metaDataJSON.corpus_size_tokens = payload.corpus_size_tokens;
|
// results.metaDataJSON.corpus_properties = payload.corpus_properties;
|
||||||
console.log(results.metaDataJSON);
|
// results.metaDataJSON.corpus_size_tokens = payload.corpus_size_tokens;
|
||||||
|
// results.metaDataJSON.corpus_all_texts = payload.corpus_all_texts;
|
||||||
|
// results.metaDataJSON.corpus_analysis_date = payload.corpus_analysis_date;
|
||||||
|
// results.metaDataJSON.corpus_cqi_py_version = payload.corpus_cqi_py_version;
|
||||||
|
// results.metaDataJSON.corpus_cqpserver_version = payload.corpus_cqpserver_version;
|
||||||
|
console.log(results.resultsMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function querySetup(payload) {
|
function querySetup(payload) {
|
||||||
|
@ -365,8 +365,8 @@
|
|||||||
// Init corpus analysis components
|
// Init corpus analysis components
|
||||||
resultsJSON = new ResultsJSON();
|
resultsJSON = new ResultsJSON();
|
||||||
resultsList = new ResultsList("result-list", resultsListOptions);
|
resultsList = new ResultsList("result-list", resultsListOptions);
|
||||||
metaDataJSON = new MetaDataJSON();
|
resultsMetaData = new ResultsMetaData();
|
||||||
results = new Results(resultsJSON, resultsList, metaDataJSON);
|
results = new Results(resultsJSON, resultsList, resultsMetaData);
|
||||||
initDisplay = new CorpusAnalysisDisplay(initDisplayElement);
|
initDisplay = new CorpusAnalysisDisplay(initDisplayElement);
|
||||||
queryDisplay = new CorpusAnalysisDisplay(queryDisplayElement);
|
queryDisplay = new CorpusAnalysisDisplay(queryDisplayElement);
|
||||||
client = new CorpusAnalysisClient({{ corpus_id }}, nopaque.socket);
|
client = new CorpusAnalysisClient({{ corpus_id }}, nopaque.socket);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user