Skip to content

Commit

Permalink
Added option to decide on models path via env var (#3)
Browse files Browse the repository at this point in the history
* Added option to decide on models path via env var

* Added wget to reqs
  • Loading branch information
zafercavdar authored Nov 10, 2021
1 parent 62e61f1 commit 222df48
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ftlangdetect/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import wget

models = {"low_mem": None, "high_mem": None}
FTLANG_CACHE = os.getenv("FTLANG_CACHE", "/tmp/fasttext-langdetect")


def download_model(name):
url = f"https://dl.fbaipublicfiles.com/fasttext/supervised-models/{name}"
target_folder = "/tmp/fasttext-langdetect"
target_path = os.path.join(target_folder, name)
target_path = os.path.join(FTLANG_CACHE, name)
if not os.path.exists(target_path):
os.makedirs(target_folder, exist_ok=True)
os.makedirs(FTLANG_CACHE, exist_ok=True)
wget.download(url=url, out=target_path)
return target_path

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fasttext >= 0.9.1
wget==3.2
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from setuptools import find_packages

setup(name='fasttext-langdetect',
version='1.0.2',
version='1.0.3',
description='80x faster and 95% accurate language identification with Fasttext',
keywords=['fasttext', 'langdetect', 'language detection',
'language identification'],
long_description=open("README.md", "r", encoding='utf-8').read(),
long_description_content_type="text/markdown",
url='https://github.com/zafercavdar/fasttext-langdetect.git',
download_url='https://github.com/zafercavdar/fasttext-langdetect/archive/refs/tags/v1.0.2.tar.gz',
download_url='https://github.com/zafercavdar/fasttext-langdetect/archive/refs/tags/v1.0.3.tar.gz',
author='Zafer Cavdar',
author_email='zafercavdar@yahoo.com',
install_requires=['fasttext >= 0.9.1'],
Expand Down

0 comments on commit 222df48

Please sign in to comment.