mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +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 math
|
||||
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_size_tokens'] = client_corpus.attrs['size']
|
||||
|
||||
texts = {}
|
||||
text_attr = client_corpus.structural_attributes.get('text')
|
||||
for text_id in range(0, (text_attr.attrs['size'])):
|
||||
texts[text_id] = {}
|
||||
logger.warning('Text ID: {}'.format(text_id))
|
||||
struct_attrs = client_corpus.structural_attributes.list(filters={'part_of': text_attr})
|
||||
text_ids = range(0, (text_attr.attrs['size']))
|
||||
texts_metadata = {}
|
||||
for text_id in text_ids:
|
||||
texts_metadata[text_id] = {}
|
||||
for struct_attr in struct_attrs:
|
||||
logger.warning(struct_attr)
|
||||
for struct_id in list(range(0, struct_attr.attrs['size'])):
|
||||
logger.warning(struct_attr.values_by_ids([struct_id]))
|
||||
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]
|
||||
metadata['corpus_all_texts'] = texts_metadata
|
||||
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
|
||||
response = {'code': 200, 'desc': 'Corpus meta data', 'msg': 'OK', 'payload': payload}
|
||||
|
@ -1,15 +1,15 @@
|
||||
class Results {
|
||||
constructor(resultsJSON, resultsList , metaDataJSON) {
|
||||
constructor(resultsJSON, resultsList , resultsMetaData) {
|
||||
this.resultsJSON = resultsJSON;
|
||||
this.resultsList = resultsList;
|
||||
this.metaDataJSON = metaDataJSON
|
||||
this.resultsMetaData = resultsMetaData
|
||||
}
|
||||
|
||||
clearAll() {
|
||||
this.resultsList.clear();
|
||||
this.resultsList.update();
|
||||
this.resultsJSON.init();
|
||||
this.metaDataJSON.init();
|
||||
this.resultsMetaData.init();
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,14 +77,10 @@ class ResultsJSON {
|
||||
}
|
||||
}
|
||||
|
||||
class MetaDataJSON {
|
||||
// Sets empty object structure. Also usefull to delete old results.
|
||||
init() {
|
||||
this["corpus_name"] = undefined;
|
||||
this["corpus_description"] = undefined;
|
||||
this["corpus_creation_date"] = undefined;
|
||||
this["corpus_last_edited_date"] = undefined;
|
||||
this["corpus_properties"] = undefined;
|
||||
this["corpus_size_tokens"] = undefined;
|
||||
class ResultsMetaData {
|
||||
// Sets empty object structure when no input is given.
|
||||
// Else it works like a delete.
|
||||
init(json = {}) {
|
||||
Object.assign(this, json);
|
||||
}
|
||||
}
|
@ -1,11 +1,16 @@
|
||||
function recvMetaData(payload) {
|
||||
results.metaDataJSON.corpus_name = payload.corpus_name;
|
||||
results.metaDataJSON.corpus_description = payload.corpus_description;
|
||||
results.metaDataJSON.corpus_creation_date = payload.corpus_creation_date;
|
||||
results.metaDataJSON.corpus_last_edited_date = payload.corpus_last_edited_date;
|
||||
results.metaDataJSON.corpus_properties = payload.corpus_properties;
|
||||
results.metaDataJSON.corpus_size_tokens = payload.corpus_size_tokens;
|
||||
console.log(results.metaDataJSON);
|
||||
results.resultsMetaData.init(payload)
|
||||
// results.metaDataJSON.corpus_name = payload.corpus_name;
|
||||
// results.metaDataJSON.corpus_description = payload.corpus_description;
|
||||
// results.metaDataJSON.corpus_creation_date = payload.corpus_creation_date;
|
||||
// results.metaDataJSON.corpus_last_edited_date = payload.corpus_last_edited_date;
|
||||
// results.metaDataJSON.corpus_properties = payload.corpus_properties;
|
||||
// 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) {
|
||||
|
@ -365,8 +365,8 @@
|
||||
// Init corpus analysis components
|
||||
resultsJSON = new ResultsJSON();
|
||||
resultsList = new ResultsList("result-list", resultsListOptions);
|
||||
metaDataJSON = new MetaDataJSON();
|
||||
results = new Results(resultsJSON, resultsList, metaDataJSON);
|
||||
resultsMetaData = new ResultsMetaData();
|
||||
results = new Results(resultsJSON, resultsList, resultsMetaData);
|
||||
initDisplay = new CorpusAnalysisDisplay(initDisplayElement);
|
||||
queryDisplay = new CorpusAnalysisDisplay(queryDisplayElement);
|
||||
client = new CorpusAnalysisClient({{ corpus_id }}, nopaque.socket);
|
||||
|
Loading…
Reference in New Issue
Block a user