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

Adding support of all languages in Duckling 0.4.24 #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Binary file not shown.
18 changes: 18 additions & 0 deletions duckling/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ class Language(object):
ESTONIAN = 'et$core'
FRENCH = 'fr$core'
IRISH = 'ga$core'
HEBREW = 'he$core'
CROATIAN = 'hr$core'
INDONESIAN = 'id$core'
ITALIAN = 'it$core'
JAPANESE = 'ja$core'
KOREAN = 'ko$core'
BIRMAN = 'my$core'
NORVEGIAN = 'nb$core'
DUTCH = 'nl$core'
POLISH = 'pl$core'
PORTUGUESE = 'pt$core'
ROMANIAN = 'ro$core'
RUSSIAN = 'ru$core'
SWEDISH = 'sv$core'
TURKISH = 'tr$core'
UKRAINIAN = 'uk$core'
VIETNAMESE = 'vi$core'
CHINESE = 'zh$core'
Expand All @@ -30,12 +39,21 @@ class Language(object):
ESTONIAN,
FRENCH,
IRISH,
HEBREW,
CROATIAN,
INDONESIAN,
ITALIAN,
JAPANESE,
KOREAN,
BIRMAN,
NORVEGIAN,
DUTCH,
POLISH,
PORTUGUESE,
ROMANIAN,
RUSSIAN,
SWEDISH,
TURKISH,
UKRAINIAN,
VIETNAMESE,
CHINESE,
Expand Down
15 changes: 15 additions & 0 deletions duckling/test/test_duckling.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from dateutil.tz import tzlocal
from duckling import Duckling, Dim, Language

all_langauges = Language.SUPPORTED_LANGUAGES
all_langauges.remove(Language.BIRMAN) # does not support arabic digits

@pytest.fixture
def test_input():
Expand Down Expand Up @@ -387,3 +389,16 @@ def test_multiple_dims(duckling_loaded):
assert len(result) == 2
assert result[0][u'value']['value'] == float(test_input)
assert result[1][u'value']['value'] == float(test_input)

@pytest.mark.parametrize("language", all_langauges)
def test_supported_languages_with_number_dim(duckling_loaded, language):
test_input = '4242'
result = duckling_loaded.parse(test_input, dim_filter=Dim.NUMBER, language=language)

print(result)

assert len(result) >= 1
assert result[0][u'dim'] == Dim.NUMBER

result_val = result[0][u'value'][u'value']
assert str(int(result_val)) == test_input