diff --git a/.github/workflows/ci-pipe-langdetect.yml b/.github/workflows/ci-pipe-langdetect.yml new file mode 100644 index 00000000..7290e68c --- /dev/null +++ b/.github/workflows/ci-pipe-langdetect.yml @@ -0,0 +1,35 @@ +on: + pull_request: + branches: [ main ] + types: + - labeled + - synchronize + +jobs: + ci-langdetect: + runs-on: ubuntu-latest + steps: + - name: Get PR Labels + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_LABELS=$(gh pr view https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} --json labels --jq '[.labels[].name]') + echo "$PR_LABELS" + echo "PR_LABELS=$PR_LABELS" >> $GITHUB_ENV + - name: Checkout + if: contains(env.PR_LABELS, 'ci-langdetect') + uses: actions/checkout@v2 + - name: Set up Python 3.7 + if: contains(env.PR_LABELS, 'ci-langdetect') + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Install dependencies + if: contains(env.PR_LABELS, 'ci-langdetect') + run: | + python -m pip install --upgrade pip + pip install pytest tox + - name: Run Test + if: contains(env.PR_LABELS, 'ci-langdetect') + run: | + tox -e langdetect \ No newline at end of file diff --git a/README.md b/README.md index c66256bd..1b6275b4 100644 --- a/README.md +++ b/README.md @@ -304,13 +304,13 @@ Lang Detect API. Thanks to awesome work from [FastText](https://fasttext.cc/docs Install extend dependencies and models ```bash - $ pip install underthesea[lang-detect] + $ pip install underthesea[langdetect] ``` Usage examples in script ```python - >>> from underthesea.pipeline.lang_detect import lang_detect + >>> from underthesea import lang_detect >>> lang_detect("Cựu binh Mỹ trả nhật ký nhẹ lòng khi thấy cuộc sống hòa bình tại Việt Nam") vi diff --git a/setup.py b/setup.py index 04e0bd94..bf3c71d2 100644 --- a/setup.py +++ b/setup.py @@ -43,8 +43,8 @@ 'prompt': [ 'openai' ], - 'lang-detect': [ - 'fasttext ' + 'langdetect': [ + 'fasttext' ] } setup( diff --git a/tox.ini b/tox.ini index 1ebd3500..0746d4b6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = traditional,deep,prompt +envlist = traditional,deep,prompt,langdetect [testenv:traditional] basepython = python3.7 @@ -62,8 +62,23 @@ setenv = OPENAI_API_KEY = {env:OPENAI_API_KEY:} commands = - ; Modules with deep learning + ; Modules with prompt pip install -e .[prompt] - ; ner module - python -m unittest tests.pipeline.classification.test_prompt \ No newline at end of file + ; prompt module + python -m unittest tests.pipeline.classification.test_prompt + +[testenv:langdetect] +basepython = python3.7 +deps= + pip>=20.3 + +setenv = + PYTHONPATH = {toxinidir}:{toxinidir}/underthesea + +commands = + ; install dependencies + pip install -e .[langdetect] + + ; lang_detect module + python -m unittest tests.pipeline.lang_detect.test_lang_detect \ No newline at end of file diff --git a/underthesea/cli.py b/underthesea/cli.py index 080cce4b..b322c54f 100644 --- a/underthesea/cli.py +++ b/underthesea/cli.py @@ -96,6 +96,7 @@ def info(): print(" classify : OK") print(" sentiment : OK") print(" dependency_parse : OK") + print(" lang_detect : OK") print(" resources : OK")