Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-233: add lang_detect pipeline #736

Merged
merged 6 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading