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

Commit

Permalink
remove caching from source
Browse files Browse the repository at this point in the history
  • Loading branch information
bedapudi6788 committed Dec 8, 2019
1 parent e79deb6 commit ed11c97
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions deeptranslit/deeptranslit.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class DeepTranslit():
model = None
words = None
lm = None
cache = None
def __init__(self, lang_code, caching=True):
def __init__(self, lang_code):
if lang_code in lang_code_mapping:
lang_code = lang_code_mapping[lang_code]

Expand All @@ -51,7 +50,6 @@ def __init__(self, lang_code, caching=True):
params_path = os.path.join(lang_path, 'params')
words_path = os.path.join(lang_path, 'words')
lm_path = os.path.join(lang_path, 'lm')
cache_path = os.path.join(lang_path, 'cache')

if not os.path.exists(lang_path):
os.mkdir(lang_path)
Expand All @@ -72,18 +70,11 @@ def __init__(self, lang_code, caching=True):
print('Downloading lm', model_links[lang_code]['lm'], 'to', lm_path)
pydload.dload(url=model_links[lang_code]['lm'], save_to_path=lm_path, max_time=None)

if not os.path.exists(cache_path):
print('Downloading cache', model_links[lang_code]['cache'], 'to', cache_path)
pydload.dload(url=model_links[lang_code]['cache'], save_to_path=cache_path, max_time=None)

DeepTranslit.model, DeepTranslit.params = build_model(params_path=params_path, enc_lstm_units=64, use_gru=True, display_summary=False)
DeepTranslit.model.load_weights(checkpoint_path)

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

if caching:
DeepTranslit.cache = pickle.load(open(cache_path, 'rb'))

if kenlm_available:
logging.warn('Loading KenLM.')
DeepTranslit.lm = kenlm.Model(lm_path)
Expand Down

0 comments on commit ed11c97

Please sign in to comment.