Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/vila/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,8 @@ def replace_unicode_tokens(
"""
tokens = tokens.copy()
for idx in range(len(tokens)):
if len(tokens[idx]) > 1:
continue
cat = unicodedata.category(tokens[idx])
if cat in unicode_categories:
logging.debug(f"Replacing {tokens[idx]} of Unicode Category {cat} with {replace_token}")
if any(unicodedata.category(ch) in unicode_categories for ch in tokens[idx]):
logging.debug(f"Replacing special unicode tokens {tokens[idx]} with {replace_token}")
tokens[idx] = replace_token

return tokens
2 changes: 1 addition & 1 deletion tests/test_vila_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_ivila_run():
def test_vila_run_with_special_unicode_inputs():

pdf_data = {
"words": ["\uf02a", "New", "Modalities"],
"words": ["\uf02a", "\uf02a\u00ad", "Modalities"],
"bbox": [
[82.806, 70.34515579999993, 123.4487846, 84.6913558],
[127.0353346, 70.34515579999993, 191.9949282, 84.6913558],
Expand Down