Skip to content

Commit

Permalink
fix: allow other mapping arguments, use on-disk alignments
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Mar 26, 2024
1 parent 629209b commit d105e5f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ jobs:
run: python -m playwright install --with-deps chromium
- name: Launch the API
run: |
pip install 'eventlet<=0.35.2'
coverage run --parallel-mode \
-m gunicorn --worker-class eventlet -w 1 g2p.app:APP --no-sendfile --bind 127.0.0.1:5000 --daemon
sleep 10
- name: Run test-studio
run: |
curl http://127.0.0.1:5000/
coverage run --parallel-mode g2p/tests/test_studio.py
- name: Run dev suite
run: coverage run --parallel-mode run_tests.py dev
- name: Run test-studio
run: coverage run --parallel-mode g2p/tests/test_studio.py
- name: Run generate-mapping
shell: bash
run: |
Expand Down
29 changes: 14 additions & 15 deletions g2p/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,22 @@ def convert(message):
mapping["abbreviations"]
)
if mapping_args["type"] == "lexicon":
transducer = make_g2p(mapping_args["in_lang"],
mapping_args["out_lang"],
tokenize=False)
transducers.append(transducer)
lexicon = Mapping.find_mapping(mapping_args["in_lang"],
mapping_args["out_lang"])
mapping_args["alignments"] = lexicon.alignments
else:
mapping_args["rules"] = mapping["rules"]
try:
mappings_obj = Mapping(**mapping_args)
transducer = Transducer(mappings_obj)
transducers.append(transducer)
except Exception as e:
LOGGER.warning(
"Skipping invalid mapping %s->%s:\n%s",
mapping_args["in_lang"],
mapping_args["out_lang"],
e,
)
try:
mappings_obj = Mapping(**mapping_args)
transducer = Transducer(mappings_obj)
transducers.append(transducer)
except Exception as e:
LOGGER.warning(
"Skipping invalid mapping %s->%s:\n%s",
mapping_args["in_lang"],
mapping_args["out_lang"],
e,
)
if len(transducers) == 0:
emit("conversion response", {"output_string": message["data"]["input_string"]})
return
Expand Down

0 comments on commit d105e5f

Please sign in to comment.