Skip to content

Commit

Permalink
improved avro dictionary structure for multiformat support
Browse files Browse the repository at this point in the history
  • Loading branch information
hitblast committed Feb 10, 2024
1 parent a9780ae commit 420084b
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 243 deletions.
20 changes: 10 additions & 10 deletions avro/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@


# Import local modules.
from .resources import AVRO_DICT
from .resources import DICT

# Shortcuts to vowels, constants, case-sensitives and numbers.
AVRO_VOWELS = set(AVRO_DICT['data']['vowel'])
AVRO_CONSONANTS = set(AVRO_DICT['data']['consonant'])
AVRO_CASESENSITIVES = set(AVRO_DICT['data']['casesensitive'])
AVRO_NUMBERS = set(AVRO_DICT['data']['number'])
AVRO_VOWELS = set(DICT['avro']['vowel'])
AVRO_CONSONANTS = set(DICT['avro']['consonant'])
AVRO_CASESENSITIVES = set(DICT['avro']['casesensitive'])
AVRO_NUMBERS = set(DICT['avro']['number'])

# Shortcuts to Bengali Svaravarna, Kar(s)
AVRO_SHORBORNO = set(AVRO_DICT['data']['shorborno'])
AVRO_KAR = AVRO_DICT['data']['kar']
AVRO_IGNORE = AVRO_DICT['data']['ignore']
EXCEPTIONS = AVRO_DICT['data']['exceptions']
AVRO_SHORBORNO = set(DICT['avro']['shorborno'])
AVRO_KAR = DICT['avro']['kar']
AVRO_IGNORE = DICT['avro']['ignore']
EXCEPTIONS = DICT['avro']['exceptions']

# Shortcuts for conversion (e.g. for Bijoy Keyboard support).
AVRO_TO_BIJ = AVRO_DICT['data']['avro_to_bijoy']
BIJOY_MAP = DICT['bijoy']['unicode_map']
6 changes: 3 additions & 3 deletions avro/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .utils import validate

# Constants.
PATTERNS = config.AVRO_DICT['data']['patterns']
PATTERNS = config.DICT['avro']['patterns']
NON_RULE_PATTERNS = [p for p in PATTERNS if 'rules' not in p]
RULE_PATTERNS = [p for p in PATTERNS if 'rules' in p]

Expand Down Expand Up @@ -105,8 +105,8 @@ def output_generator() -> Generator[str, None, None]:
def convert_to_bijoy(text: str) -> str:
text = re.sub('ৌ', 'ৌ', re.sub('ো', 'ো', text))

for unic in config.AVRO_TO_BIJ:
text = re.sub(unic, config.AVRO_TO_BIJ[unic], text)
for unic in config.BIJOY_MAP:
text = re.sub(unic, config.BIJOY_MAP[unic], text)

return text.strip()

Expand Down
Loading

0 comments on commit 420084b

Please sign in to comment.