Skip to content

Commit

Permalink
refactor: remove one more temp and replace with curr
Browse files Browse the repository at this point in the history
  • Loading branch information
nsantacruz committed Aug 31, 2023
1 parent 24eb4cf commit 1524825
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sefaria/helper/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,18 @@ def find_text_to_remove(self, s, **kwargs):
mappings = []
snorm = s
for step in self.steps:
temp_text_to_remove = step.find_text_to_remove(snorm, **kwargs)
if len(temp_text_to_remove) == 0:
curr_text_to_remove = step.find_text_to_remove(snorm, **kwargs)
if len(curr_text_to_remove) == 0:
text_to_remove_inds, text_to_remove_repls = [], []
else:
text_to_remove_inds, text_to_remove_repls = zip(*temp_text_to_remove)
text_to_remove_inds, text_to_remove_repls = zip(*curr_text_to_remove)
for mapping in reversed(mappings):
text_to_remove_inds = step.convert_normalized_indices_to_unnormalized_indices(text_to_remove_inds, mapping)
temp_text_to_remove = list(zip(text_to_remove_inds, text_to_remove_repls))
curr_text_to_remove = list(zip(text_to_remove_inds, text_to_remove_repls))

# merge any overlapping ranges
# later edits should override earlier ones
final_text_to_remove = self.merge_removal_inds(final_text_to_remove, temp_text_to_remove)
final_text_to_remove = self.merge_removal_inds(final_text_to_remove, curr_text_to_remove)
mappings += [step.get_mapping_after_normalization(snorm, **kwargs)]
snorm = step.normalize(snorm, **kwargs)
final_text_to_remove.sort(key=lambda x: x[0])
Expand Down

0 comments on commit 1524825

Please sign in to comment.