Skip to content

Commit

Permalink
update deep context model.
Browse files Browse the repository at this point in the history
  • Loading branch information
shibing624 committed Nov 8, 2023
1 parent 8f10fb7 commit a4c2a89
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pycorrector/deepcontext/deepcontext_corrector.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ def __init__(
model_dir = os.path.join(USER_DATA_DIR, 'deepcontext_models', 'deepcontext_lm')
logger.debug(f'Use default model: {model_dir}')
filename = 'deepcontext_lm.tar.gz'
url = pretrained_deepcontext_models.get(filename)
get_file(
filename,
url,
extract=True,
cache_dir=USER_DATA_DIR,
cache_subdir="deepcontext_models",
verbose=1
)
checkpoint_file = os.path.join(model_dir, "pytorch_model.bin")
url = pretrained_deepcontext_models.get(filename, '')
if url and not os.path.exists(checkpoint_file):
get_file(
filename,
url,
extract=True,
cache_dir=USER_DATA_DIR,
cache_subdir="deepcontext_models",
verbose=1
)
t1 = time.time()
self.model = DeepContextModel(model_dir=model_dir, max_length=max_length, use_cuda=use_cuda)
self.model.load_model()
Expand Down

0 comments on commit a4c2a89

Please sign in to comment.