Skip to content

Commit

Permalink
Change languages available in dlt.lang (#35)
Browse files Browse the repository at this point in the history
* Change languages available in dlt.lang

* Add Khmer as a language for m2m100

* scripts/generate_lang.py

* Update available languages in the docs

* Update tests for dlt.lang

* Apply black

* Bump version

* Fix tests (replace space by _)
  • Loading branch information
Xing Han Lu authored Apr 9, 2021
1 parent f0c091b commit a6f7410
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions dl_translate/_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
("Javanese", "jv"),
("Georgian", "ka"),
("Kazakh", "kk"),
("Khmer", "km"),
("Central Khmer", "km"),
("Kannada", "kn"),
("Korean", "ko"),
Expand Down
4 changes: 2 additions & 2 deletions dl_translate/lang/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .mbart50 import *
from . import m2m100
from .m2m100 import *
from . import m2m100, mbart50
1 change: 1 addition & 0 deletions dl_translate/lang/m2m100.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
JAVANESE = "Javanese"
GEORGIAN = "Georgian"
KAZAKH = "Kazakh"
KHMER = "Khmer"
CENTRAL_KHMER = "Central Khmer"
KANNADA = "Kannada"
KOREAN = "Korean"
Expand Down
1 change: 1 addition & 0 deletions docs/available_languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ This page gives all the languages available for each model family.
- Javanese (jv)
- Georgian (ka)
- Kazakh (kk)
- Khmer (km)
- Central Khmer (km)
- Kannada (kn)
- Korean (ko)
Expand Down
1 change: 1 addition & 0 deletions scripts/langs_coverage/m2m100.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"Javanese": "jv",
"Georgian": "ka",
"Kazakh": "kk",
"Khmer": "km",
"Central Khmer": "km",
"Kannada": "kn",
"Korean": "ko",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="dl-translate",
version="0.2.1",
version="0.2.2",
author="Xing Han Lu",
author_email="github@xinghanlu.com",
description="A deep learning-based translation library built on Huggingface transformers",
Expand Down
13 changes: 9 additions & 4 deletions tests/quick/test_lang.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import dl_translate as dlt
from dl_translate._pairs import _PAIRS_MBART50
from dl_translate._pairs import _PAIRS_MBART50, _PAIRS_M2M100


def test_lang():
for l, _ in _PAIRS_MBART50:
assert getattr(dlt.lang, l.upper()) == l
for l, _ in _PAIRS_M2M100:
assert getattr(dlt.lang, l.upper().replace(" ", "_")) == l


def test_lang_m2m100():
for l, _ in _PAIRS_M2M100:
assert getattr(dlt.lang.m2m100, l.upper().replace(" ", "_")) == l


def test_lang_mbart50():
for l, _ in _PAIRS_MBART50:
assert getattr(dlt.lang.mbart50, l.upper()) == l
assert getattr(dlt.lang.mbart50, l.upper().replace(" ", "_")) == l

0 comments on commit a6f7410

Please sign in to comment.