Unroll get_matching last list-comprehension.
This commit is contained in:
parent
e6cbb54382
commit
7cdf8a310d
@ -278,14 +278,23 @@ def get_matching(sample, other):
|
||||
x[0][i][0] == sample[0][i][0],
|
||||
other))
|
||||
|
||||
return [sample[0][x] if isinstance(sample[0][x], str)
|
||||
else
|
||||
sample[0][x] if isinstance(sample[0][x], tuple)
|
||||
else {'groups': sample[0][x]['groups'] & reduce(lambda a, b: a & b,
|
||||
map(lambda y: y[0][x]['groups'],
|
||||
other))}
|
||||
for x
|
||||
in range(l)]
|
||||
matching = []
|
||||
for x in range(l): # Generate the combination of this and other(s) matcher
|
||||
first_sample_data = sample[0][x]
|
||||
if isinstance(first_sample_data, str):
|
||||
matching.append(first_sample_data)
|
||||
elif isinstance(first_sample_data, tuple):
|
||||
matching.append(first_sample_data)
|
||||
else:
|
||||
this_groups = sample[0][x]['groups']
|
||||
if len(other) > 0:
|
||||
other_groups = reduce(lambda a, b: a & b,
|
||||
map(lambda y: y[0][x]['groups'],
|
||||
other))
|
||||
this_groups = this_groups & other_groups
|
||||
|
||||
matching.append({'groups': this_groups})
|
||||
return matching
|
||||
|
||||
|
||||
def reprocess_language_knowledge(knowledge_base, examples):
|
||||
|
Loading…
Reference in New Issue
Block a user