diff --git a/README.md b/README.md index 5decde2..66b715a 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,9 @@ $ pip install avnie ## 🔖 Usage Guide -This small tour guide will describe how you can use avro.py back and forth to operate (cutlery!) on Bengali text: +This small tour guide will describe how you can use avro.py back and forth to operate (cutlery!) on Bengali text. You can also check the [examples](https://github.com/hitblast/avro.py/tree/main/examples) directory for checking [this whole snippet](https://github.com/hitblast/avro.py/blob/main/examples/simple.py) in action, as well as other use cases. -### 1. `parse()` +#### 1. `parse()` Let's assume I want to parse some English text to Bengali, which is "ami banglay gan gai.", so in this case to convert it to Bengali, we can use this snippet: ```python @@ -74,7 +74,7 @@ avro_output = avro.parse(dummy) print(output) # Output: আমি বাংলায় গান গাই। ``` -### 2. `parse(bijoy=True)` +#### 2. `parse(bijoy=True)` Alternatively, I can also do it in Bijoy Keyboard format: ```python @@ -82,23 +82,23 @@ Alternatively, I can also do it in Bijoy Keyboard format: bijoy_output = avro.parse(dummy, bijoy=True) # Output: Avwg evsjvh় Mvb MvB। ``` -### 3. `to_bijoy()` +#### 3. `to_bijoy()` Or, we can take the previous `avro_output` and convert it to Bijoy if we want to, like this: ```python # Converting to Bijoy. -bijoy_text = avro.to_bijoy(avro_output) +bijoy_text = avro.to_bijoy(avro_output) # Output: Avwg evsjvh় Mvb MvB। ``` -### 4. `to_unicode()` +#### 4. `to_unicode()` Conversely, we can convert the Bijoy text we got just now and convert it back to Unicode Bengali: ```python # Converting back! -unicode_text = avro.to_unicode(bijoy_text) +unicode_text = avro.to_unicode(bijoy_text) # Output: আমি বাংলায় গান গাই। ``` -### 4. `reverse()` +#### 4. `reverse()` Finally, we can just reverse back to the original text we passed as input in the first place: ```python diff --git a/examples/simple.py b/examples/simple.py new file mode 100644 index 0000000..11150e7 --- /dev/null +++ b/examples/simple.py @@ -0,0 +1,28 @@ +# Import the package. +import avro + +# Let's assume we'd like to convert "amar sOnar bangla" to Unicode. +dummy_text = "amar sOnar bangla" +print("Original English Text:", dummy_text) + +# Parse the text to Avro. +parsed_text = avro.parse(dummy_text) +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) + +# Print the Bijoy 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)