mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Add more visualization data
This commit is contained in:
parent
972f514e6b
commit
f037c31b88
@ -50,9 +50,52 @@ def cqi_corpora_corpus_update_db(cqi_client: cqi.CQiClient, corpus_name: str):
|
|||||||
@cqi_over_socketio
|
@cqi_over_socketio
|
||||||
def cqi_corpora_corpus_get_visualization_data(cqi_client: cqi.CQiClient, corpus_name: str):
|
def cqi_corpora_corpus_get_visualization_data(cqi_client: cqi.CQiClient, corpus_name: str):
|
||||||
corpus = cqi_client.corpora.get(corpus_name)
|
corpus = cqi_client.corpora.get(corpus_name)
|
||||||
|
# s_attrs = [x for x in corpus.structural_attributes.list() if not x.has_values]
|
||||||
|
# p_attrs = corpus.positional_attributes.list()
|
||||||
|
# payload = {
|
||||||
|
# 's_attrs': {},
|
||||||
|
# 'p_attrs': {},
|
||||||
|
# 'values': {
|
||||||
|
# 's_attrs': {},
|
||||||
|
# 'p_attrs': {}
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# for s_attr in s_attrs:
|
||||||
|
# s_attr_lbound, s_attr_rbound = s_attr.cpos_by_id(text_id)
|
||||||
|
# s_attr_cpos_range = range(s_attr_lbound, s_attr_rbound + 1)
|
||||||
|
# payload['text']['lexicon'][text_id] = {
|
||||||
|
# 's_attrs': [s_attr_lbound, s_attr_rbound],
|
||||||
|
# 'counts': {
|
||||||
|
# 'token': s_attr_rbound - s_attr_lbound + 1
|
||||||
|
# },
|
||||||
|
# 'freqs': {
|
||||||
|
# p_attr.name: dict(Counter(p_attr.ids_by_cpos(list(s_attr_cpos_range))))
|
||||||
|
# for p_attr in p_attrs
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# for p_attr in p_attrs:
|
||||||
|
# payload['p_attrs'] = dict(
|
||||||
|
|
||||||
|
# )
|
||||||
|
# payload['values']['p_attrs'] = dict(
|
||||||
|
# zip(
|
||||||
|
# range(0, p_attr.lexicon_size),
|
||||||
|
# p_attr.values_by_ids(list(range(0, p_attr.lexicon_size)))
|
||||||
|
# )
|
||||||
|
# )
|
||||||
text = corpus.structural_attributes.get('text')
|
text = corpus.structural_attributes.get('text')
|
||||||
|
text_value_names = []
|
||||||
|
text_values = []
|
||||||
|
for text_sub_attr in corpus.structural_attributes.list(filters={'part_of': text}):
|
||||||
|
text_value_names.append(text_sub_attr.name[(len(text.name) + 1):])
|
||||||
|
text_values.append(text_sub_attr.values_by_ids(list(range(0, text.size))))
|
||||||
s = corpus.structural_attributes.get('s')
|
s = corpus.structural_attributes.get('s')
|
||||||
ent = corpus.structural_attributes.get('ent')
|
ent = corpus.structural_attributes.get('ent')
|
||||||
|
ent_value_names = []
|
||||||
|
ent_values = []
|
||||||
|
for ent_sub_attr in corpus.structural_attributes.list(filters={'part_of': ent}):
|
||||||
|
ent_value_names.append(ent_sub_attr.name[(len(ent.name) + 1):])
|
||||||
|
ent_values.append(ent_sub_attr.values_by_ids(list(range(0, ent.size))))
|
||||||
word = corpus.positional_attributes.get('word')
|
word = corpus.positional_attributes.get('word')
|
||||||
lemma = corpus.positional_attributes.get('lemma')
|
lemma = corpus.positional_attributes.get('lemma')
|
||||||
pos = corpus.positional_attributes.get('pos')
|
pos = corpus.positional_attributes.get('pos')
|
||||||
@ -122,10 +165,7 @@ def cqi_corpora_corpus_get_visualization_data(cqi_client: cqi.CQiClient, corpus_
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
payload['text']['values'] = [
|
payload['text']['values'] = text_value_names
|
||||||
sub_attr.name[(len(text.name) + 1):]
|
|
||||||
for sub_attr in corpus.structural_attributes.list(filters={'part_of': text})
|
|
||||||
]
|
|
||||||
payload['s'] = {'lexicon': {}, 'values': None}
|
payload['s'] = {'lexicon': {}, 'values': None}
|
||||||
for s_id in range(0, s.size):
|
for s_id in range(0, s.size):
|
||||||
payload['s']['lexicon'][s_id] = {
|
payload['s']['lexicon'][s_id] = {
|
||||||
@ -140,15 +180,22 @@ def cqi_corpora_corpus_get_visualization_data(cqi_client: cqi.CQiClient, corpus_
|
|||||||
payload['ent']['lexicon'][ent_id] = {
|
payload['ent']['lexicon'][ent_id] = {
|
||||||
# 'bounds': ent.cpos_by_id(ent_id)
|
# 'bounds': ent.cpos_by_id(ent_id)
|
||||||
}
|
}
|
||||||
payload['ent']['values'] = [
|
payload['ent']['values'] = ent_value_names
|
||||||
sub_attr.name[(len(ent.name) + 1):]
|
|
||||||
for sub_attr in corpus.structural_attributes.list(filters={'part_of': ent})
|
|
||||||
]
|
|
||||||
payload['lookups'] = {
|
payload['lookups'] = {
|
||||||
'corpus': {},
|
'corpus': {},
|
||||||
'text': {},
|
'text': {
|
||||||
|
text_id: {
|
||||||
|
text_value_name: text_values[text_value_name_idx][text_id_idx]
|
||||||
|
for text_value_name_idx, text_value_name in enumerate(text_value_names)
|
||||||
|
} for text_id_idx, text_id in enumerate(range(0, text.size))
|
||||||
|
},
|
||||||
's': {},
|
's': {},
|
||||||
'ent': {},
|
'ent': {
|
||||||
|
ent_id: {
|
||||||
|
ent_value_name: ent_values[ent_value_name_idx][ent_id_idx]
|
||||||
|
for ent_value_name_idx, ent_value_name in enumerate(ent_value_names)
|
||||||
|
} for ent_id_idx, ent_id in enumerate(range(0, ent.size))
|
||||||
|
},
|
||||||
'word': dict(
|
'word': dict(
|
||||||
zip(
|
zip(
|
||||||
range(0, word.lexicon_size),
|
range(0, word.lexicon_size),
|
||||||
|
@ -34,6 +34,7 @@ class CorpusAnalysisApp {
|
|||||||
.then(
|
.then(
|
||||||
cQiCorpus => {
|
cQiCorpus => {
|
||||||
this.data.corpus = {o: cQiCorpus};
|
this.data.corpus = {o: cQiCorpus};
|
||||||
|
this.data.corpus.o.getVisualizationData().then(data => console.log(data));
|
||||||
// this.data.corpus.o.getVisualizationData()
|
// this.data.corpus.o.getVisualizationData()
|
||||||
// .then(
|
// .then(
|
||||||
// (visualizationData) => {
|
// (visualizationData) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user