Skip to content

Commit

Permalink
Allow custom reversed_pre_processor_mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Feb 25, 2020
1 parent efda446 commit 9333f24
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/transliterate/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class TranslitLanguagePack(object):
mapping = None
reversed_specific_mapping = None

reversed_pre_processor_mapping = None # Added
reversed_pre_processor_mapping_keys = []

reversed_specific_pre_processor_mapping = None
Expand Down Expand Up @@ -141,14 +142,18 @@ def __init__(self):

# If any pre-processor rules defined, reversing them for later use.
if self.pre_processor_mapping:
self.reversed_pre_processor_mapping = dict(
zip(
self.pre_processor_mapping.values(),
self.pre_processor_mapping.keys())
)
self.pre_processor_mapping_keys = self.pre_processor_mapping.keys()
# If no `reversed_pre_processor_mapping` is defined, construct
# from `pre_processor_mapping`.
if not self.reversed_pre_processor_mapping:
self.reversed_pre_processor_mapping = dict(
zip(
self.pre_processor_mapping.values(),
self.pre_processor_mapping.keys()
)
)
self.reversed_pre_processor_mapping_keys = \
self.pre_processor_mapping.values()
self.reversed_pre_processor_mapping.keys()

else:
self.reversed_pre_processor_mapping = None
Expand Down

0 comments on commit 9333f24

Please sign in to comment.