forked from WDAqua/Qanary-question-answering-components
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow configuration of source and target languages
- Loading branch information
Showing
11 changed files
with
292 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM python:3.7 | ||
FROM python:3.10 | ||
|
||
COPY requirements.txt ./ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
[pytest] | ||
log_cli = 0 | ||
log_cli = 1 | ||
log_cli_level = INFO | ||
log_cli_format = %(asctime)s [%(levelname)8s] [%(filename)s:%(lineno)s] %(message)s | ||
log_cli_date_format=%Y-%m-%d %H:%M:%S | ||
env = | ||
SERVER_PORT=40120 | ||
SERVICE_PORT=40120 | ||
SERVICE_HOST=http://public-component-host | ||
SPRING_BOOT_ADMIN_URL=http://qanary-pipeline-host:40111 | ||
SERVER_HOST=http://public-component-host | ||
SPRING_BOOT_ADMIN_CLIENT_INSTANCE_SERVICE-BASE-URL=http://public-component-host:40120 | ||
SPRING_BOOT_ADMIN_USERNAME=admin | ||
SPRING_BOOT_ADMIN_PASSWORD=admin | ||
SERVICE_NAME_COMPONENT=MT-MBart | ||
SERVICE_NAME_COMPONENT=MT-MBart-Component | ||
SERVICE_DESCRIPTION_COMPONENT=Translates question to English | ||
SOURCE_LANGUAGE=de | ||
TARGET_LANGUAGE=en |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
Flask | ||
langdetect==1.0.9 | ||
langid==1.1.6 | ||
mock==3.0.5 | ||
python-dotenv==0.21.1 | ||
Flask==3.0.3 | ||
pytest==8.3.2 | ||
pytest-env==1.1.3 | ||
qanary_helpers==0.2.2 | ||
transformers==4.41.0 | ||
sentencepiece==0.1.97 | ||
torch==2.3.0 | ||
gunicorn==20.1.0 | ||
protobuf==3.20.* | ||
pytest | ||
pytest-env | ||
SentencePiece==0.2.0 | ||
SPARQLWrapper==2.0.0 | ||
torch==2.4.0 | ||
transformers==4.44.0 | ||
qanary-helpers==0.2.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import logging | ||
from unittest import mock | ||
from unittest import TestCase | ||
import os | ||
import importlib | ||
|
||
class TestLangUtils(TestCase): | ||
|
||
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO) | ||
|
||
@mock.patch.dict(os.environ, {'SOURCE_LANGUAGE': 'fr'}) | ||
def test_only_one_source_language(self): | ||
import utils.lang_utils | ||
importlib.reload(utils.lang_utils) | ||
from utils.lang_utils import translation_options | ||
assert 'fr' in translation_options.keys() | ||
assert len(translation_options.keys()) == 1 | ||
|
||
|
||
@mock.patch.dict(os.environ, {'TARGET_LANGUAGE': 'ru'}) | ||
def test_only_one_target_language(self): | ||
import utils.lang_utils | ||
importlib.reload(utils.lang_utils) | ||
from utils.lang_utils import translation_options | ||
# all 5 non-russian source languages should support 'ru' | ||
assert len(translation_options.items()) == 5 | ||
# but each item should only contain the one target language! | ||
assert ('en', ['ru']) in translation_options.items() | ||
assert ('de', ['ru']) in translation_options.items() | ||
assert ('es', ['ru']) in translation_options.items() | ||
assert ('fr', ['ru']) in translation_options.items() | ||
assert ('pt', ['ru']) in translation_options.items() | ||
|
||
|
||
@mock.patch.dict(os.environ, {'SOURCE_LANGUAGE': 'en', 'TARGET_LANGUAGE': 'es'}) | ||
def test_specific_source_and_target_language(self): | ||
import utils.lang_utils | ||
importlib.reload(utils.lang_utils) | ||
from utils.lang_utils import translation_options | ||
assert translation_options == {'en': ['es']} | ||
|
||
|
||
@mock.patch.dict(os.environ, {'SOURCE_LANGUAGE': 'zh'}) | ||
def test_unsupported_source_language_raises_error(self): | ||
try: | ||
import utils.lang_utils | ||
importlib.reload(utils.lang_utils) | ||
except ValueError as ve: | ||
logging.error(ve) | ||
pass | ||
|
||
|
||
@mock.patch.dict(os.environ, {'SOURCE_LANGUAGE': 'en', 'TARGET_LANGUAGE': 'zh'}) | ||
def test_unsupported_target_for_source_language_raises_error(self): | ||
try: | ||
import utils.lang_utils | ||
importlib.reload(utils.lang_utils) | ||
except ValueError as ve: | ||
logging.error(ve) | ||
pass | ||
|
||
|
||
@mock.patch.dict(os.environ, {'TARGET_LANGUAGE': 'zh'}) | ||
def test_unsupported_target_language_raises_error(self): | ||
try: | ||
import utils.lang_utils | ||
importlib.reload(utils.lang_utils) | ||
except ValueError as ve: | ||
logging.error(ve) | ||
pass |
Oops, something went wrong.