Skip to content

Commit

Permalink
GH-233: add lang_detect pipeline (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
rain1024 committed Jun 9, 2024
1 parent 8fee5e9 commit d8d2159
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 8 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci-pipe-langdetect.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
'prompt': [
'openai'
],
'lang-detect': [
'fasttext '
'langdetect': [
'fasttext'
]
}
setup(
Expand Down
23 changes: 19 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = traditional,deep,prompt
envlist = traditional,deep,prompt,langdetect

[testenv:traditional]
basepython = python3.7
Expand Down Expand Up @@ -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
; 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
1 change: 1 addition & 0 deletions underthesea/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def info():
print(" classify : OK")
print(" sentiment : OK")
print(" dependency_parse : OK")
print(" lang_detect : OK")
print(" resources : OK")


Expand Down

0 comments on commit d8d2159

Please sign in to comment.