mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Fix context size and codestyle
This commit is contained in:
parent
9a1efbe5f3
commit
7c8ae161a9
@ -130,7 +130,8 @@ class StructuralAttribute(Attribute):
|
||||
else:
|
||||
cpos_list_lbound = first_cpos
|
||||
rc_rbound = \
|
||||
self.cpos_by_id(min((last_id + context), (self.attrs['size'] - 1)))[1]
|
||||
self.cpos_by_id(min((last_id + context),
|
||||
(self.attrs['size'] - 1)))[1]
|
||||
if rc_rbound != last_cpos:
|
||||
rc_lbound = min((last_cpos + 1),
|
||||
(self.collection.corpus.attrs['size'] - 1))
|
||||
|
@ -30,14 +30,16 @@ class Corpus(Model):
|
||||
for attr in self.positional_attributes.list():
|
||||
cpos_attr_values = attr.values_by_cpos(cpos_list)
|
||||
for i, cpos in enumerate(cpos_list):
|
||||
lookups['cpos_lookup'][cpos][attr.attrs['name']] = cpos_attr_values[i]
|
||||
lookups['cpos_lookup'][cpos][attr.attrs['name']] = \
|
||||
cpos_attr_values[i]
|
||||
for attr in self.structural_attributes.list():
|
||||
if attr.attrs['has_values']:
|
||||
continue
|
||||
cpos_attr_ids = attr.ids_by_cpos(cpos_list)
|
||||
for i, cpos in enumerate(cpos_list):
|
||||
if cpos_attr_ids[i] != -1:
|
||||
lookups['cpos_lookup'][cpos][attr.attrs['name']] = cpos_attr_ids[i]
|
||||
lookups['cpos_lookup'][cpos][attr.attrs['name']] = \
|
||||
cpos_attr_ids[i]
|
||||
occured_attr_ids = list(filter(lambda x: x != -1,
|
||||
set(cpos_attr_ids)))
|
||||
if not occured_attr_ids:
|
||||
@ -53,7 +55,8 @@ class Corpus(Model):
|
||||
for subattr in subattrs:
|
||||
subattr_values = subattr.values_by_ids(occured_attr_ids)
|
||||
for i, subattr_value in enumerate(subattr_values):
|
||||
subattr_name = subattr.attrs['name'][(len(attr.attrs['name']) + 1):]
|
||||
subattr_name = \
|
||||
subattr.attrs['name'][(len(attr.attrs['name']) + 1):]
|
||||
lookups[lookup_name][occured_attr_ids[i]][subattr_name] = \
|
||||
subattr_value
|
||||
return lookups
|
||||
|
@ -37,9 +37,10 @@ class Subcorpus(Model):
|
||||
return {"matches": []}
|
||||
first_match = max(0, offset)
|
||||
last_match = min((offset + cutoff - 1), (self.attrs['size'] - 1))
|
||||
match_boundaries = \
|
||||
zip(self.dump(self.attrs['fields']['match'], first_match, last_match), # noqa
|
||||
self.dump(self.attrs['fields']['matchend'], first_match, last_match)) # noqa
|
||||
match_boundaries = zip(self.dump(self.attrs['fields']['match'],
|
||||
first_match, last_match),
|
||||
self.dump(self.attrs['fields']['matchend'],
|
||||
first_match, last_match))
|
||||
cpos_list = []
|
||||
matches = []
|
||||
for match_start, match_end in match_boundaries:
|
||||
@ -50,7 +51,7 @@ class Subcorpus(Model):
|
||||
else:
|
||||
lc_rbound = max(0, (match_start - 1))
|
||||
if lc_rbound != match_start:
|
||||
lc_lbound = max(0, (match_start - 1 - context))
|
||||
lc_lbound = max(0, (match_start - context))
|
||||
lc = (lc_lbound, lc_rbound)
|
||||
cpos_list_lbound = lc_lbound
|
||||
else:
|
||||
@ -58,7 +59,7 @@ class Subcorpus(Model):
|
||||
rc_lbound = min((match_end + 1),
|
||||
(self.collection.corpus.attrs['size'] - 1))
|
||||
if rc_lbound != match_end:
|
||||
rc_rbound = min((match_end + 1 + context),
|
||||
rc_rbound = min((match_end + context),
|
||||
(self.collection.corpus.attrs['size'] - 1))
|
||||
rc = (rc_lbound, rc_rbound)
|
||||
cpos_list_rbound = rc_rbound
|
||||
|
Loading…
Reference in New Issue
Block a user