Skip to content

Commit

Permalink
fix: Check distance between two chars
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnasism committed Feb 23, 2024
1 parent 61e14fe commit 8c6dacc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hotpdf/memory_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ def load_memory_map(
prev_char_inserted = char_c != " "
# Insert into Trie and Span Maps
last_inserted_x_y: tuple[int, int] = (-1, -1)
# TODO: Constant distance for now - needs research
ANNOTATION_DISTANCE_THRESHOLD = 5
for i in range(len(char_hot_characters)):
_current_character: HotCharacter = char_hot_characters[i]
# Determine if annotation spaces should be added
if include_annotation_spaces and i > 0 and i < len(char_hot_characters) - 1:
prev_char: HotCharacter = char_hot_characters[i - 1]
next_char: HotCharacter = char_hot_characters[i + 1]
if _current_character.is_anno and (not (next_char.x - prev_char.x_end) >= 5):
if _current_character.is_anno and (not (next_char.x - prev_char.x) >= ANNOTATION_DISTANCE_THRESHOLD):
continue

# Prevent characters from overlapping
Expand Down

0 comments on commit 8c6dacc

Please sign in to comment.