Skip to content

Commit

Permalink
fix encoding issue on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yannvgn committed Nov 1, 2019
1 parent c79c33c commit 75d134d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions laserembeddings/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ def print_usage():


def download_file(url, dest):
print(f'⏳ Downloading {url}...', end='')
print(f'⏳ Downloading {url}...'.encode('utf8'), end='')
sys.stdout.flush()
urllib.request.urlretrieve(url, dest)
print(f'\r✅ Downloaded {url} ')


def extract_tar(tar, output_dir):
print(f'⏳ Extracting archive...', end='')
print(f'⏳ Extracting archive...'.encode('utf8'), end='')
sys.stdout.flush()
with tarfile.open(tar) as t:
t.extractall(output_dir)
print(f'\r✅ Extracted archive ')
print(f'\r✅ Extracted archive '.encode('utf8'))


def download_models(output_dir):
Expand All @@ -49,7 +49,7 @@ def download_models(output_dir):
os.path.join(output_dir, 'bilstm.93langs.2018-12-26.pt'))

print('')
print("✨ You\'re all set!")
print("✨ You\'re all set!".encode('utf8'))


def download_and_extract_test_data(output_dir):
Expand All @@ -64,7 +64,7 @@ def download_and_extract_test_data(output_dir):
output_dir)

print('')
print("✨ Ready to test all that!")
print("✨ Ready to test all that!".encode('utf8'))


def main():
Expand Down Expand Up @@ -93,7 +93,7 @@ def main():
if os.path.basename(repository_root) != 'laserembeddings':
print(
"❌ Looks like you're not running laserembeddings from its source code"
)
.encode('utf8'))
print(
" → please checkout https://github.com/yannvgn/laserembedings.git"
)
Expand Down
6 changes: 3 additions & 3 deletions laserembeddings/laser.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ def __init__(self,
if not os.path.isfile(self.DEFAULT_BPE_CODES_FILE):
raise FileNotFoundError(
'93langs.fcodes is missing, run "python -m laserembeddings download-models" to fix that 🔧'
)
.encode('utf8'))
bpe_codes = self.DEFAULT_BPE_CODES_FILE
if bpe_vocab is None:
if not os.path.isfile(self.DEFAULT_BPE_VOCAB_FILE):
raise FileNotFoundError(
'93langs.fvocab is missing, run "python -m laserembeddings download-models" to fix that 🔧'
)
.encode('utf8'))
bpe_vocab = self.DEFAULT_BPE_VOCAB_FILE
if encoder is None:
if not os.path.isfile(self.DEFAULT_ENCODER_FILE):
raise FileNotFoundError(
'bilstm.93langs.2018-12-26.pt is missing, run "python -m laserembeddings download-models" to fix that 🔧'
)
.encode('utf8'))
encoder = self.DEFAULT_ENCODER_FILE

self.tokenizer_options = tokenizer_options
Expand Down
2 changes: 1 addition & 1 deletion tests/test_laser.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_similarity(test_data):
if not test_data:
raise FileNotFoundError(
'laserembeddings-test-data.npz is missing, run "python -m laserembeddings download-test-data" to fix that 🔧'
)
.encode('utf8'))

report = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'report', 'comparison-with-LASER.md')
Expand Down

0 comments on commit 75d134d

Please sign in to comment.