Skip to content

Commit

Permalink
updated markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
hitblast committed Aug 8, 2024
1 parent a8bf34a commit f845581
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
43 changes: 28 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,35 +57,48 @@ $ pip install avnie

## 🔖 Usage Guide

### 1. `parse()`
This is the most basic use case for avro.py, which includes parsing English Roman script to unicode Bengali:
This small tour guide will describe how you can use avro.py back and forth to operate (cutlery! lame joke?) on Bengali text:

#### 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
# Imports.
# Import the package.
import avro

# Parsing some text.
output = avro.parse('ami banglay gan gai.')
print(output)
# Our dummy text.
dummy = 'ami banglay gan gai.'

# Parsing the text.
avro_output = avro.parse(dummy)
print(output) # Output: আমি বাংলায় গান গাই।
```

#### 2. `parse(bijoy=True)`
Alternatively, I can also do it in Bijoy Keyboard format:

```python
# Parsing in Bijoy.
bijoy_output = avro.parse(dummy, bijoy=True) # Output: Avwg evsjvh় Mvb MvB।
```

### 2. `parse(bijoy=True)`
Alternatively, we can generate the same output, but in compliance with the Bijoy Keyboard format:
#### 3. `to_bijoy()`
Or, we can take the previous `avro_output` and convert it to Bijoy if we want to, like this:

```python
# Parsing some text in Bijoy!
output = avro.parse('tumi emon keno?', bijoy=True)
# Converting...
bijoy_output = avro.to_bijoy(avro_output) # Output: Avwg evsjvh় Mvb MvB।
```

### 3. `to_bijoy()`
We can also use avro.py to convert existing unicode Bengali to its Bijoy Keyboard equivalent:
#### 4. `to_unicode()`
Conversely, we can convert Bijoy Keyboard text to unicode Bengali:

```python
# Converting some text.
bijoy_text = avro.to_bijoy('আমি বাংলায় গান গাই।')
# Converting back!
unicode_text = avro.to_unicode('Avwg evsjvh় Mvb MvB।') # Output: আমি বাংলায় গান গাই।
```

### 4. `reverse()`
#### 5. `reverse()`
Finally, you can reverse unicode Bengali to English as well (newly added).

```python
Expand Down
9 changes: 4 additions & 5 deletions avro/utils/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,23 +323,22 @@ def rearrange_bijoy_text(text: str) -> str:
j += 1
else:
break
temp = text[: i - j] + text[i] + text[i + 1] + text[i - j : i] + text[i + 2 :]
text = temp
text = text[: i - j] + text[i] + text[i + 1] + text[i - j : i] + text[i + 2 :]
i += 1
continue

if i < len(text) - 1 and validate.is_bangla_prekar(text[i]) and text[i + 1] != " ":
j = 1
while validate.is_bangla_banjonborno(text[i + j]):
if validate.is_bangla_halant(text[i + j + 1]):
if validate.is_bangla_halant((part := text[i + j + 1])):
j += 2
else:
break
temp = text[:i] + text[i + 1 : i + j + 1]
if text[i] == "ে" and text[i + j + 1] == "া":
if text[i] == "ে" and part == "া":
temp += "ো"
l = 1
elif text[i] == "ে" and text[i + j + 1] == "ৗ":
elif text[i] == "ে" and part == "ৗ":
temp += "ৌ"
l = 1
else:
Expand Down

0 comments on commit f845581

Please sign in to comment.