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

Small recipe and configuration updates #126

Merged
merged 3 commits into from
Apr 27, 2022
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
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ max-complexity = 10
max-line-length = 100
application-import-names = aalto_asr_preprocessor,tests
import-order-style = google
per-file-ignores = tests/*:S101, src/aalto_asr_preprocessor/__main__.py:S101
per-file-ignores = tests/*:S101
rst-roles = class,const,func,meth,mod,ref
rst-directives = deprecated
6 changes: 4 additions & 2 deletions src/aalto_asr_preprocessor/fi/parl_to_kaldi_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def lowercase(match: Match[str]) -> Any:
r"((?:\d+(?: [a-z])?, )*\d+(?: [a-z])?(?:—|-| ja ))?(\d+(?: *[a-z])?) *§:?([a-zåäö]*)",
expand_numbers_with_section_sign,
),
(r"§:?([a-zåäö])", expand_section_sign),
(r"§:?([a-zåäö]+)", expand_section_sign),
# Ruotsinkielisessä tekstissä pykälämerkki tulee ennen numeroa. Käsitellään toistaiseksi näin
# koska pelkällä poistolla virheet edellisessä regexpissä jäävät huomaamatta = This format
# appears in Swedish texts, handle like this for now so errors with above regexp aren't missed
Expand Down Expand Up @@ -467,7 +467,7 @@ def lowercase(match: Match[str]) -> Any:
(r"[.:?!]\s+", r"\n"),
# Muut välimerkit = Other punctuation
(r"[!\?;…\/]", r"\n"),
(r"[>¤¶†ªðк¨¦¾Þ\\©®þ\«,­¸:_\»<=&\*()\]¿¡#@~\"'`´‘’“”]", r""),
(r"[>¤¶†ªðк¨¦¾Þ\\©®þ\«,­¸:_\»<=&\*()\]¿¡§#@~\"'`´‘’“”]", r""),
(r"\s?—\s?", r" "),
# Loput pisteet pois = Remove rest of periods
(r"\.", r" "),
Expand Down Expand Up @@ -512,6 +512,8 @@ def lowercase(match: Match[str]) -> Any:
"ş": "s",
"ß": "ss",
"ž": "z",
"ğ": "g",
"ł": "l",
# Weird special characters encountered in Swedish text
"ı": "i",
"fi": "fi",
Expand Down
4 changes: 4 additions & 0 deletions tests/fi/test_parl_to_kaldi_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ def test_kaldi_preprocessor_with_long_text(parl_to_kaldi_test_pairs: Tuple[str,
"arvoisa puhemies kysymyksessä on siis eduskunnalle annettava tämän vuoden toiseen "
"lisätalousarvioon liittyvä täydentävä hallituksen esitys",
),
(
"nähden nämä 58 c ja d §:ien määräykset",
"nähden nämä viisikymmentäkahdeksan c ja d pykälien määräykset",
),
],
)
def test_kaldi_preprocessor_with_short_text(input_text: str, true_result: str) -> None:
Expand Down