Skip to content

Commit

Permalink
new from_bijoy flag allows direct reversal from bijoy to english
Browse files Browse the repository at this point in the history
  • Loading branch information
hitblast committed Aug 11, 2024
1 parent 9a5bb0f commit 4cb07f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion avro/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def to_unicode(*texts):

# The reverse() function.
# Used to parse from Bengali in Unicode to English Roman script.
def reverse(*texts: str, remap_words: bool = True) -> Union[str, List[str]]:
def reverse(*texts: str, from_bijoy: bool = False, remap_words: bool = True) -> Union[str, List[str]]:
"""
#### Reverses input text to Roman script typed in English.
Expand All @@ -244,5 +244,11 @@ def reverse(*texts: str, remap_words: bool = True) -> Union[str, List[str]]:
```
"""

# Convert from Bijoy to Unicode if from_bijoy is True
if from_bijoy:
texts = to_unicode(*texts)
if isinstance(texts, str):
texts = (texts,)

output = _concurrency_helper(lambda text: _reverse_backend_ext(text, remap_words), texts)
return output[0] if len(output) == 1 else output
3 changes: 3 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,6 @@ def test_full_sentences() -> NoReturn:
"rohim, tomake korim dakche. ekhon ki rowna debe?",
"rowna dile amake bole zew.",
] == avro.reverse("রহিম, তোমাকে করিম ডাকছে। এখন কি রওনা দেবে?", "রওনা দিলে আমাকে বলে যেও।")

# Reverse (Bijoy Settings).
assert "ami banglar gan gai." == avro.reverse("Avwg evsjvi Mvb MvB|", from_bijoy=True)

0 comments on commit 4cb07f2

Please sign in to comment.