Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Commit 1891f63

Browse files
committed
move rank optio to init
1 parent ed11c97 commit 1891f63

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

deeptranslit/deeptranslit.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class DeepTranslit():
3434
model = None
3535
words = None
3636
lm = None
37-
def __init__(self, lang_code):
37+
rank = 'auto'
38+
39+
def __init__(self, lang_code, rank='auto'):
3840
if lang_code in lang_code_mapping:
3941
lang_code = lang_code_mapping[lang_code]
4042

@@ -75,11 +77,13 @@ def __init__(self, lang_code):
7577

7678
DeepTranslit.words = pickle.load(open(words_path, 'rb'))
7779

78-
if kenlm_available:
80+
if kenlm_available and rank in {'auto', 'kenlm'}:
7981
logging.warn('Loading KenLM.')
8082
DeepTranslit.lm = kenlm.Model(lm_path)
83+
DeepTranslit.rank = rank
8184

82-
def transliterate(self, sent, rank='auto', top=3):
85+
def transliterate(self, sent, top=3):
86+
rank = DeepTranslit.rank
8387
words = sent.strip().split()
8488
puncs = []
8589
for i, word in enumerate(words):

0 commit comments

Comments
 (0)