Skip to content

Commit ad39e99

Browse files
committed
remove dead code and simplify
1 parent d0136b0 commit ad39e99

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

unstructured/metrics/text_extraction.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
"」": "U+FF63", # HALFWIDTH RIGHT CORNER BRACKET
5151
}
5252

53-
_TRANSLATION_TABLE = {}
53+
_TRANSLATION_TABLE = str.maketrans(
54+
{chr(int(v.replace("U+", ""), 16)): '"' for v in _DOUBLE_QUOTES.values()}
55+
| {chr(int(v.replace("U+", ""), 16)): "'" for v in _SINGLE_QUOTES.values()}
56+
)
5457

5558

5659
def calculate_accuracy(
@@ -223,23 +226,3 @@ def standardize_quotes(text: str) -> str:
223226
return text.translate(_TRANSLATION_TABLE)
224227

225228

226-
def unicode_to_char(unicode_val: str) -> str:
227-
"""
228-
Converts a Unicode value to a character.
229-
230-
Args:
231-
unicode_val (str): The Unicode value to convert.
232-
233-
Returns:
234-
str: The character corresponding to the Unicode value.
235-
"""
236-
return chr(int(unicode_val.replace("U+", ""), 16))
237-
238-
239-
for unicode_val in _DOUBLE_QUOTES.values():
240-
char_code = int(unicode_val.replace("U+", ""), 16)
241-
_TRANSLATION_TABLE[char_code] = ord('"')
242-
243-
for unicode_val in _SINGLE_QUOTES.values():
244-
char_code = int(unicode_val.replace("U+", ""), 16)
245-
_TRANSLATION_TABLE[char_code] = ord("'")

0 commit comments

Comments
 (0)