Spaces:
Sleeping
Sleeping
reference after space
Browse files- annotations.py +3 -1
annotations.py
CHANGED
@@ -65,6 +65,9 @@ def highlight_issues_in_pdf(file, language_matches: List[Dict[str, Any]]) -> byt
|
|
65 |
words = page.get_text("words") # List of tuples: (x0, y0, x1, y1, "word", block_no, line_no, word_no)
|
66 |
for w in words:
|
67 |
word_text = w[4]
|
|
|
|
|
|
|
68 |
word_list.append((page_number, word_text, w[0], w[1], w[2], w[3]))
|
69 |
print(f"Total words extracted: {len(word_list)}")
|
70 |
|
@@ -121,7 +124,6 @@ def highlight_issues_in_pdf(file, language_matches: List[Dict[str, Any]]) -> byt
|
|
121 |
except Exception as e:
|
122 |
print(f"Error in highlighting PDF: {e}")
|
123 |
return b""
|
124 |
-
|
125 |
def analyze_pdf(file) -> Tuple[Dict[str, Any], bytes]:
|
126 |
"""Analyzes the PDF for language issues and returns results and annotated PDF."""
|
127 |
try:
|
|
|
65 |
words = page.get_text("words") # List of tuples: (x0, y0, x1, y1, "word", block_no, line_no, word_no)
|
66 |
for w in words:
|
67 |
word_text = w[4]
|
68 |
+
# **Fix:** Insert a space before '[' to ensure "globally [2]" instead of "globally[2]"
|
69 |
+
if '[' in word_text:
|
70 |
+
word_text = word_text.replace('[', ' [')
|
71 |
word_list.append((page_number, word_text, w[0], w[1], w[2], w[3]))
|
72 |
print(f"Total words extracted: {len(word_list)}")
|
73 |
|
|
|
124 |
except Exception as e:
|
125 |
print(f"Error in highlighting PDF: {e}")
|
126 |
return b""
|
|
|
127 |
def analyze_pdf(file) -> Tuple[Dict[str, Any], bytes]:
|
128 |
"""Analyzes the PDF for language issues and returns results and annotated PDF."""
|
129 |
try:
|