mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 10:54:18 +00:00
Update cqi utils
This commit is contained in:
parent
5c00c5740e
commit
1387d80a26
@ -9,8 +9,7 @@ def lookups_by_cpos(corpus: CQiCorpus, cpos_list: List[int]) -> Dict:
|
|||||||
for attr in corpus.positional_attributes.list():
|
for attr in corpus.positional_attributes.list():
|
||||||
cpos_attr_values: List[str] = attr.values_by_cpos(cpos_list)
|
cpos_attr_values: List[str] = attr.values_by_cpos(cpos_list)
|
||||||
for i, cpos in enumerate(cpos_list):
|
for i, cpos in enumerate(cpos_list):
|
||||||
lookups['cpos_lookup'][cpos][attr.attrs['name']] = \
|
lookups['cpos_lookup'][cpos][attr.name] = cpos_attr_values[i]
|
||||||
cpos_attr_values[i]
|
|
||||||
for attr in corpus.structural_attributes.list():
|
for attr in corpus.structural_attributes.list():
|
||||||
# We only want to iterate over non subattributes, identifiable by
|
# We only want to iterate over non subattributes, identifiable by
|
||||||
# attr.has_values == False
|
# attr.has_values == False
|
||||||
@ -20,19 +19,19 @@ def lookups_by_cpos(corpus: CQiCorpus, cpos_list: List[int]) -> Dict:
|
|||||||
for i, cpos in enumerate(cpos_list):
|
for i, cpos in enumerate(cpos_list):
|
||||||
if cpos_attr_ids[i] == -1:
|
if cpos_attr_ids[i] == -1:
|
||||||
continue
|
continue
|
||||||
lookups['cpos_lookup'][cpos][attr.attrs['name']] = cpos_attr_ids[i]
|
lookups['cpos_lookup'][cpos][attr.name] = cpos_attr_ids[i]
|
||||||
occured_attr_ids = [x for x in set(cpos_attr_ids) if x != -1]
|
occured_attr_ids = [x for x in set(cpos_attr_ids) if x != -1]
|
||||||
if not occured_attr_ids:
|
if len(occured_attr_ids) == 0:
|
||||||
continue
|
continue
|
||||||
subattrs = corpus.structural_attributes.list(filters={'part_of': attr})
|
subattrs = corpus.structural_attributes.list(filters={'part_of': attr})
|
||||||
if not subattrs:
|
if len(subattrs) == 0:
|
||||||
continue
|
continue
|
||||||
lookup_name: str = f'{attr.attrs["name"]}_lookup'
|
lookup_name: str = f'{attr.name}_lookup'
|
||||||
lookups[lookup_name] = {}
|
lookups[lookup_name] = {}
|
||||||
for attr_id in occured_attr_ids:
|
for attr_id in occured_attr_ids:
|
||||||
lookups[lookup_name][attr_id] = {}
|
lookups[lookup_name][attr_id] = {}
|
||||||
for subattr in subattrs:
|
for subattr in subattrs:
|
||||||
subattr_name = subattr.attrs['name'][(len(attr.attrs['name']) + 1):] # noqa
|
subattr_name = subattr.name[(len(attr.name) + 1):] # noqa
|
||||||
for i, subattr_value in enumerate(subattr.values_by_ids(occured_attr_ids)): # noqa
|
for i, subattr_value in enumerate(subattr.values_by_ids(occured_attr_ids)): # noqa
|
||||||
lookups[lookup_name][occured_attr_ids[i]][subattr_name] = subattr_value # noqa
|
lookups[lookup_name][occured_attr_ids[i]][subattr_name] = subattr_value # noqa
|
||||||
return lookups
|
return lookups
|
||||||
|
Loading…
Reference in New Issue
Block a user