Commit 8b6e7818 authored by Vít Starý Novotný's avatar Vít Starý Novotný
Browse files

Fail softly in `Document.get_sentence()`

parent de307fef
Loading
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -104,7 +104,8 @@ class Document:
            else:
                full_left_context = f'{previous_page.text} {full_left_context}'
                left_context_match = regex.match(left_context_regex, full_left_context)
                assert left_context_match is not None, f'No sentence was found in {previous_page}'
                if left_context_match is None:
                    return None
                left_context = left_context_match.group('left_context')
        else:
            left_context = left_context_match.group('left_context')
@@ -121,7 +122,8 @@ class Document:
            else:
                full_right_context = f'{full_right_context} {next_page.text}'
                right_context_match = regex.match(right_context_regex, full_right_context)
                assert right_context_match is not None, f'No sentence was found in {next_page}'
                if right_context_match is None:
                    return None
                right_context = right_context_match.group('right_context')
        else:
            right_context = right_context_match.group('right_context')