Fix mixed-direction text layout in translations (Resolves #34)#37
Open
Salah-Sal wants to merge 1 commit into
Open
Fix mixed-direction text layout in translations (Resolves #34)#37Salah-Sal wants to merge 1 commit into
Salah-Sal wants to merge 1 commit into
Conversation
* remove redundant line the line removed was redundant - the `source_text` gets already replaced through the f"-string * Update utils.py
abodacs
suggested changes
Nov 15, 2024
abodacs
left a comment
There was a problem hiding this comment.
@Salah-Sal
Thanks for your contribution.
I added some comments
| words_and_delimiters = re.findall(r"\w+|[^\w\s]+|\s+", text) | ||
|
|
||
| new_text = [] | ||
| ltr_pattern = re.compile( |
There was a problem hiding this comment.
@Salah-Sal
Thanks for your contribution.
can we modify the ltr_pattern to include numerical digits?
ltr_pattern = re.compile("[A-Za-z0-9]+")| is_rtl = language in rtl_languages | ||
|
|
||
| # Regex to capture words, non-word characters, and any whitespace | ||
| words_and_delimiters = re.findall(r"\w+|[^\w\s]+|\s+", text) |
There was a problem hiding this comment.
Can we pre-compile the regular expression outside for better performance?
tokenizer_pattern = re.compile(r"\w+|[^\w\s]+|\s+")
# ... Inside the function:
words_and_delimiters = tokenizer_pattern.findall(text)| "Urdu", | ||
| } | ||
| is_rtl = language in rtl_languages | ||
|
|
There was a problem hiding this comment.
I suggest adding an appropriate normalization form, but it may lead to the removal of unimportant text, so you can neglect it.
# . , before tokenizaText:
text = unicodedata.normalize("NFC", text)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
What is the purpose of this PR? Is it to
Please link to any issues this PR addresses.
Fixes #34
Changelog
Test plan
Please make sure to do each of the following if applicable to your PR. (If you're not sure about any one of these just ask and we will happily help.)
pre-commit install)pytest tests