From cce92b4d776175641f34875b97ed9e90a9992cc7 Mon Sep 17 00:00:00 2001 From: HitBlast Date: Mon, 9 Dec 2024 20:55:14 +0600 Subject: [PATCH] updated examples and finalized markdown --- README.md | 8 ++++++-- examples/{simple.py => async.py} | 12 +++++++----- examples/basic.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) rename examples/{simple.py => async.py} (72%) create mode 100644 examples/basic.py diff --git a/README.md b/README.md index 722f21c..95d4b21 100644 --- a/README.md +++ b/README.md @@ -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.
+> [!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.
## ✨ Inspirations @@ -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: diff --git a/examples/simple.py b/examples/async.py similarity index 72% rename from examples/simple.py rename to examples/async.py index 15fa14a..295fd8e 100644 --- a/examples/simple.py +++ b/examples/async.py @@ -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) diff --git a/examples/basic.py b/examples/basic.py new file mode 100644 index 0000000..ff4e4db --- /dev/null +++ b/examples/basic.py @@ -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()