Skip to content

Commit

Permalink
updated examples and finalized markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
hitblast committed Dec 9, 2024
1 parent 2ee7538 commit cce92b4
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ A modern Pythonic implementation of the popular Bengali phonetic-typing software

**avro.py** provides a fully fledged, batteries-included text parser which can parse, reverse and even convert English Roman script into its phonetic equivalent (unicode) of Bengali. At its core, it implements an extensively modified version of the **Avro Phonetic Dictionary Search Library** by [Mehdi Hasan Khan](https://github.com/mugli).

> Update: As of October 2024, Python 3.8 has reached its EOL, so for keeping this project updated, the minimum required version will be Python 3.9 from now onwards. It is strongly suggested that you migrate your project for better compatibility. <br>
> [!NOTE]
> Update: As of October 2024, Python 3.8 has reached its EOL, so for keeping
> this project updated, the minimum required version will be Python 3.9 from now
> onwards. It is strongly suggested that you migrate your project for better
> compatibility. <br>
## ✨ Inspirations

Expand Down Expand Up @@ -116,7 +120,7 @@ Since version [2024.12.5](https://github.com/hitblast/avro.py/releases/tag/2024.
> [!NOTE]
> Unless you have a very specific use, the asynchronous functions only
> provide slight performance improvements and are not necessary for most use
> cases.e, the asynchronous functions only provide slight performance improvements
> cases, the asynchronous functions only provide slight performance improvements
> and are not necessary for most use cases.
Here's a reiteration of the previous example using the new syntax:
Expand Down
12 changes: 7 additions & 5 deletions examples/simple.py → examples/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ async def main() -> None:
dummy_text = "amar sOnar bangla" # Dummy text.
print("Original English Text:", dummy_text)

parsed_text = await avro.parse(dummy_text) # Parse the text to Bengali.
parsed_text = await avro.parse_async(
dummy_text
) # Parse the text to Bengali.
print("Parsed Unicode Output:", parsed_text)

# We can parse it directly to Bijoy, or use the to_bijoy function to convert it.
# Both should return the same result.
bijoy_text_direct = await avro.parse(dummy_text, bijoy=True)
bijoy_text_function = await avro.to_bijoy(parsed_text)
bijoy_text_direct = await avro.parse_async(dummy_text, bijoy=True)
bijoy_text_function = await avro.to_bijoy_async(parsed_text)

if bijoy_text_direct == bijoy_text_function:
print(f"Bijoy Output: {bijoy_text_direct}")

# Now, we can return the Bijoy text to Unicode since we'd like the original output (assuming).
# This should be the same as the old parsed_text variable.
unicode_text = await avro.to_unicode(bijoy_text_direct)
unicode_text = await avro.to_unicode_async(bijoy_text_direct)
print("Reversed Unicode Output:", unicode_text)

# Finally, we can reverse the Bengali text, back to English!
reversed = await avro.reverse(unicode_text)
reversed = await avro.reverse_async(unicode_text)
print("Reversed English Output:", reversed)


Expand Down
32 changes: 32 additions & 0 deletions examples/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Imports.
import avro


# Please follow the detailed guidelines given in the README.md file about each function to learn more.
def main() -> None:
dummy_text = "amar sOnar bangla" # Dummy text.
print("Original English Text:", dummy_text)

parsed_text = avro.parse(dummy_text) # Parse the text to Bengali.
print("Parsed Unicode Output:", parsed_text)

# We can parse it directly to Bijoy, or use the to_bijoy function to convert it.
# Both should return the same result.
bijoy_text_direct = avro.parse(dummy_text, bijoy=True)
bijoy_text_function = avro.to_bijoy(parsed_text)

if bijoy_text_direct == bijoy_text_function:
print(f"Bijoy Output: {bijoy_text_direct}")

# Now, we can return the Bijoy text to Unicode since we'd like the original output (assuming).
# This should be the same as the old parsed_text variable.
unicode_text = avro.to_unicode(bijoy_text_direct)
print("Reversed Unicode Output:", unicode_text)

# Finally, we can reverse the Bengali text, back to English!
reversed = avro.reverse(unicode_text)
print("Reversed English Output:", reversed)


if __name__ == "__main__":
main()

0 comments on commit cce92b4

Please sign in to comment.