Refactoring: Rename

This commit is contained in:
Matthias Bisping 2023-01-17 09:54:50 +01:00
parent 8d34873d1c
commit 232c6bed4b

View File

@ -16,6 +16,7 @@ from faker import Faker
from matplotlib import pyplot as plt
from cv_analysis.utils import star, rconj
from cv_analysis.utils.merging import merge_related_rectangles
Image_t = Union[Image.Image, np.ndarray]
#
@ -463,17 +464,17 @@ class RandomTextBlock(ContentRectangle):
# This is meant to be read from the bottom up.
current_line_shall_not_be_a_full_line = truncate_current_line()
line_processor = self.truncate_line if current_line_shall_not_be_a_full_line else identity
process_current_line = compose(line_processor, first)
line_formatter = self.truncate_line if current_line_shall_not_be_a_full_line else identity
format_current_line = compose(line_formatter, first)
move_current_line_to_back = star(rconj)
split_first_line_from_lines_and_process_the_former = juxt(rest, process_current_line)
split_off_current_line_then_process_it_then_move_it_to_the_back = rcompose(
split_first_line_from_lines_and_process_the_former,
split_first_line_from_lines_and_format_the_former = juxt(rest, format_current_line)
split_off_current_line_then_format_it_then_move_it_to_the_back = rcompose(
split_first_line_from_lines_and_format_the_former,
move_current_line_to_back,
)
current_line_is_a_full_line = not current_line_shall_not_be_a_full_line
# Start reading here and move up.
return current_line_is_a_full_line, split_off_current_line_then_process_it_then_move_it_to_the_back(lines)
return current_line_is_a_full_line, split_off_current_line_then_format_it_then_move_it_to_the_back(lines)
def format_line(self, line, full=True):
line = self.truncate_line(line) if not full else line
@ -519,7 +520,8 @@ class PagePartitioner:
box = Rectangle(left_margin, top_margin, page.width - right_margin, page.height - bottom_margin)
boxes = lflatten(self.generate_content_boxes(box))
boxes = self.drop_small_boxes(boxes, *page.size)
# boxes = self.drop_small_boxes(boxes, *page.size)
# boxes = merge_related_rectangles(boxes)
boxes = list(boxes)
return boxes