mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-12 17:10:41 +00:00
Add metadata object on analysis
This commit is contained in:
@ -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})
|
||||
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}
|
||||
|
Reference in New Issue
Block a user