python_code
stringlengths 0
679k
| repo_name
stringlengths 9
41
| file_path
stringlengths 6
149
|
---|---|---|
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestMoney:
inverse_normalizer = InverseNormalizer(lang='pt', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('pt/data_inverse_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/pt/test_money.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestWhitelist:
inverse_normalizer = InverseNormalizer(lang='pt', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('pt/data_inverse_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/pt/test_whitelist.py |
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestOrdinal:
normalizer_zh = Normalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('zh/data_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_date(self, test_input, expected):
preds = self.normalizer_zh.normalize(test_input)
assert expected == preds
inverse_normalizer = InverseNormalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('zh/data_inverse_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_ordinal.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestMeasure:
normalizer_zh = Normalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('zh/data_text_normalization/test_cases_measure.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_measure(self, test_input, expected):
preds = self.normalizer_zh.normalize(test_input)
assert expected == preds
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_measure.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestTime:
normalizer_zh = Normalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('zh/data_text_normalization/test_cases_time.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_time(self, test_input, expected):
preds = self.normalizer_zh.normalize(test_input)
assert expected == preds
# inverse_normalizer = InverseNormalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False)
# @parameterized.expand(parse_test_case_file('zh/data_inverse_text_normalization/test_cases_time.txt'))
# @pytest.mark.run_only_on('CPU')
# @pytest.mark.unit
# def test_denorm(self, test_input, expected):
# pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
# assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_time.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestDate:
normalizer_zh = Normalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('zh/data_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_date(self, test_input, expected):
preds = self.normalizer_zh.normalize(test_input)
assert expected == preds
inverse_normalizer = InverseNormalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('zh/data_inverse_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_decimal.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestFraction:
normalizer_zh = Normalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('zh/data_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_fraction(self, test_input, expected):
preds = self.normalizer_zh.normalize(test_input)
assert expected == preds
inverse_normalizer = InverseNormalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('zh/data_inverse_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_fraction.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
| NeMo-text-processing-main | tests/nemo_text_processing/zh/__init__.py |
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestCardinal:
normalizer_zh = Normalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('zh/data_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_date(self, test_input, expected):
preds = self.normalizer_zh.normalize(test_input)
assert expected == preds
inverse_normalizer = InverseNormalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('zh/data_inverse_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_cardinal.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestDate:
normalizer_zh = Normalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('zh/data_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_date(self, test_input, expected):
preds = self.normalizer_zh.normalize(test_input)
assert expected == preds
inverse_normalizer = InverseNormalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('zh/data_inverse_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_date.py |
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestWord:
inverse_normalizer = InverseNormalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('zh/data_inverse_text_normalization/test_cases_word.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_word.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestPreprocess:
normalizer_zh = Normalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('zh/data_text_normalization/test_cases_preprocess.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_preprocess(self, test_input, expected):
preds = self.normalizer_zh.normalize(test_input)
assert expected == preds
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_preprocess.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestMath:
normalizer_zh = Normalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('zh/data_text_normalization/test_cases_math.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_math(self, test_input, expected):
preds = self.normalizer_zh.normalize(test_input)
assert expected == preds
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_math.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestMoney:
normalizer_zh = Normalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('zh/data_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_money(self, test_input, expected):
preds = self.normalizer_zh.normalize(test_input)
assert expected == preds
inverse_normalizer = InverseNormalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('zh/data_inverse_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_money.py |
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestWhitelist:
inverse_normalizer = InverseNormalizer(lang='zh', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('zh/data_inverse_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/zh/test_whitelist.py |
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from parameterized import parameterized
from tests.nemo_text_processing.utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
try:
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
PYNINI_AVAILABLE = True
except (ImportError, ModuleNotFoundError):
PYNINI_AVAILABLE = False
class TestMeasure:
inverse_normalizer = (
InverseNormalizer(lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False) if PYNINI_AVAILABLE else None
)
@parameterized.expand(parse_test_case_file('ar/data_inverse_text_normalization/test_cases_measure.txt'))
@pytest.mark.skipif(
not PYNINI_AVAILABLE,
reason="`pynini` not installed, please install via nemo_text_processing/pynini_install.sh",
)
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = (
Normalizer(input_case='cased', lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
if PYNINI_AVAILABLE
else None
)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS and PYNINI_AVAILABLE
else None
)
@parameterized.expand(parse_test_case_file('ar/data_text_normalization/test_cases_measure.txt'))
@pytest.mark.skipif(
not PYNINI_AVAILABLE,
reason="`pynini` not installed, please install via nemo_text_processing/pynini_install.sh",
)
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/ar/test_measure.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from tests.nemo_text_processing.utils import CACHE_DIR, parse_test_case_file
class TestDecimal:
inverse_normalizer_ar = InverseNormalizer(
lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False
) # if PYNINI_AVAILABLE else None
@parameterized.expand(parse_test_case_file('ar/data_inverse_text_normalization/test_cases_decimal.txt'))
# @pytest.mark.skipif(
# not PYNINI_AVAILABLE, reason="`pynini` not installed, please install via nemo_text_processing/setup.sh"
# )
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer_ar.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer_ar = Normalizer(
lang='ar', input_case="cased", cache_dir=CACHE_DIR, overwrite_cache=False, post_process=True
)
# normalizer_with_audio_en = (
# NormalizerWithAudio(input_case='cased', lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
# if PYNINI_AVAILABLE and RUN_AUDIO_BASED_TESTS
# else None
# )
@parameterized.expand(parse_test_case_file('ar/data_text_normalization/test_cases_decimal.txt'))
# @pytest.mark.skipif(
# not PYNINI_AVAILABLE, reason="`pynini` not installed, please install via nemo_text_processing/setup.sh"
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_ar.normalize(test_input, verbose=False)
assert pred == expected
# if self.normalizer_with_audio_ar:
# pred_non_deterministic = self.normalizer_with_audio_ar.normalize(
# test_input, n_tagged=30, punct_post_process=False,
# )
# assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/ar/test_decimal.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from tests.nemo_text_processing.utils import CACHE_DIR, parse_test_case_file
class TestFraction:
inverse_normalizer = InverseNormalizer(lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('ar/data_inverse_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR
else None
)
@parameterized.expand(parse_test_case_file('ar/data_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/ar/test_fraction.py |
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
| NeMo-text-processing-main | tests/nemo_text_processing/ar/__init__.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from tests.nemo_text_processing.utils import CACHE_DIR, parse_test_case_file
class TestCardinal:
inverse_normalizer_ar = InverseNormalizer(lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('ar/data_inverse_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer_ar.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer_ar = Normalizer(
input_case='cased', lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False, post_process=True
)
@parameterized.expand(parse_test_case_file('ar/data_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_ar.normalize(test_input, verbose=False, punct_post_process=False)
assert pred == expected, f"input: {test_input}"
| NeMo-text-processing-main | tests/nemo_text_processing/ar/test_cardinal.py |
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from tests.nemo_text_processing.utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestMoney:
inverse_normalizer = InverseNormalizer(lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('ar/data_inverse_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected, f"input: {test_input}"
normalizer = Normalizer(input_case='cased', lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
if RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('ar/data_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected, f"input: {test_input}"
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=30, punct_post_process=False,
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/ar/test_money.py |
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from tests.nemo_text_processing.utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestWhitelist:
inverse_normalizer = InverseNormalizer(lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('ar/data_inverse_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected, f"input: {test_input}"
normalizer = Normalizer(input_case='cased', lang='ar', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('ar/data_inverse_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected, f"input: {test_input}"
| NeMo-text-processing-main | tests/nemo_text_processing/ar/test_whitelist.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestOrdinal:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_ordinal.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestMeasure:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_measure.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_measure.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestTime:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_time.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_time.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestDecimal:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_decimal.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestFraction:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_fraction.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
| NeMo-text-processing-main | tests/nemo_text_processing/hu/__init__.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestElectronic:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_electronic.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_electronic.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestTelephone:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_telephone.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_telephone.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestCardinal:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_cardinal.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestDate:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_date.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestWord:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_word.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_word.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestMoney:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_money.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestWhitelist:
normalizer_hu = Normalizer(input_case='cased', lang='hu', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('hu/data_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_hu.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/hu/test_whitelist.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
| NeMo-text-processing-main | tests/nemo_text_processing/hu/data_text_normalization/__init__.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestOrdinal:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_ordinal.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestMeasure:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_measure.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_measure.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_measure.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestTime:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_time.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_time.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_time.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestDecimal:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_decimal.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import pytest
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, get_test_cases_multiple
class TestNormalizeWithAudio:
normalizer_de = NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(get_test_cases_multiple('de/data_text_normalization/test_cases_normalize_with_audio.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_de.normalize(test_input, n_tagged=1000, punct_post_process=False)
logging.info(expected)
logging.info("pred")
logging.info(pred)
assert len(set(pred).intersection(set(expected))) == len(
expected
), f'missing: {set(expected).difference(set(pred))}'
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_normalization_with_audio.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestFraction:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_fraction.py |
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
| NeMo-text-processing-main | tests/nemo_text_processing/de/__init__.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestElectronic:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_electronic.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_electronic.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_electronic.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestTelephone:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_telephone.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_telephone.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_telephone.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestCardinal:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_cardinal.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestDate:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_date.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestWord:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_word.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_word.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_word.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestMoney:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_money.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestWhitelist:
inverse_normalizer = InverseNormalizer(lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('de/data_inverse_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='de', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('de/data_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, expected, test_input):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=1000, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/de/test_whitelist.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestOrdinal:
inverse_normalizer = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_ordinal.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestMeasure:
inverse_normalizer_es = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_measure.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_measure.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestTime:
inverse_normalizer_es = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_time.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_time.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestDecimal:
inverse_normalizer = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_decimal.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestFraction:
inverse_normalizer = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.inverse_normalizer.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_fraction.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/__init__.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestElectronic:
inverse_normalizer_es = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_electronic.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_electronic.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestTelephone:
inverse_normalizer_es = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_telephone.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_telephone.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestCardinal:
inverse_normalizer = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_cardinal.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestDate:
inverse_normalizer = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_date.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestWord:
inverse_normalizer_es = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_word.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_word.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestMoney:
inverse_normalizer = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_money.py |
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestWhitelist:
inverse_normalizer_es = InverseNormalizer(lang='es_en', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es_en/data_inverse_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/es_en/test_whitelist.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestOrdinal:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('fr/data_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_ordinal.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestMeasure:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_measure.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_measure.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestTime:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_time.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_time.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestDecimal:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('fr/data_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_decimal.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestFraction:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('fr/data_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_fraction.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
| NeMo-text-processing-main | tests/nemo_text_processing/fr/__init__.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestElectronic:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_electronic.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_electronic.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestTelephone:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_telephone.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_telephone.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestCardinal:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False, input_case='cased')
@parameterized.expand(parse_test_case_file('fr/data_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred in expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_cardinal.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestDate:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_date.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestWord:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_word.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_word.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestMoney:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_money.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestWhitelist:
inverse_normalizer = InverseNormalizer(lang='fr', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('fr/data_inverse_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
| NeMo-text-processing-main | tests/nemo_text_processing/fr/test_whitelist.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestOrdinal:
inverse_normalizer = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred in expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=500, punct_post_process=False,
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_ordinal.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestMeasure:
inverse_normalizer_es = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_measure.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_measure.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred in expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=500, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_measure.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestTime:
inverse_normalizer_es = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_time.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_time.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=500, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_time.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestDecimal:
inverse_normalizer = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred in expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=500, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_decimal.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, get_test_cases_multiple
class TestNormalizeWithAudio:
normalizer_es = NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(get_test_cases_multiple('es/data_text_normalization/test_cases_normalize_with_audio.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_es.normalize(test_input, n_tagged=50, punct_post_process=False)
print(expected)
print("pred")
print(pred)
assert len(set(pred).intersection(set(expected))) == len(
expected
), f'missing: {set(expected).difference(set(pred))}'
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_normalization_with_audio.py |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestFraction:
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=500, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_fraction.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
| NeMo-text-processing-main | tests/nemo_text_processing/es/__init__.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestElectronic:
inverse_normalizer_es = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_electronic.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_electronic.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=500, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_electronic.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestTelephone:
inverse_normalizer_es = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_telephone.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_telephone.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred in expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=30, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_telephone.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestCardinal:
inverse_normalizer = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_cardinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=500, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_cardinal.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestDate:
inverse_normalizer = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = NormalizerWithAudio(
input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_date.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=500, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_date.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestWord:
inverse_normalizer_es = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_word.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer_es = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio_es = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_word.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_es.normalize(test_input, verbose=False)
assert pred == expected, f"input: {test_input}"
if self.normalizer_with_audio_es:
pred_non_deterministic = self.normalizer_with_audio_es.normalize(
test_input, n_tagged=150, punct_post_process=False
)
assert expected in pred_non_deterministic, f"input: {test_input}"
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_word.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestMoney:
inverse_normalizer = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_money.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=500, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_money.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestWhitelist:
inverse_normalizer_es = InverseNormalizer(lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
@parameterized.expand(parse_test_case_file('es/data_inverse_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm_es(self, test_input, expected):
pred = self.inverse_normalizer_es.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer = Normalizer(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio = (
NormalizerWithAudio(input_case='cased', lang='es', cache_dir=CACHE_DIR, overwrite_cache=False)
if CACHE_DIR and RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('es/data_text_normalization/test_cases_whitelist.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio:
pred_non_deterministic = self.normalizer_with_audio.normalize(
test_input, n_tagged=10, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/es/test_whitelist.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestOrdinal:
inverse_normalizer_en = InverseNormalizer(lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
inverse_normalizer_en_cased = InverseNormalizer(
lang='en', cache_dir=CACHE_DIR, overwrite_cache=False, input_case="cased"
)
@parameterized.expand(parse_test_case_file('en/data_inverse_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer_en.inverse_normalize(test_input, verbose=False)
assert pred == expected
pred = self.inverse_normalizer_en_cased.inverse_normalize(test_input, verbose=False)
assert pred == expected
@parameterized.expand(parse_test_case_file('en/data_inverse_text_normalization/test_cases_ordinal_cased.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer_en_cased.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer_en = Normalizer(input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio_en = (
NormalizerWithAudio(input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
if RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('en/data_text_normalization/test_cases_ordinal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_en.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio_en:
pred_non_deterministic = self.normalizer_with_audio_en.normalize(
test_input, n_tagged=30, punct_post_process=False,
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/en/test_ordinal.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from parameterized import parameterized
from ..utils import CACHE_DIR, parse_test_case_file
class TestPunctuation:
normalizer_en = Normalizer(
input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False, post_process=True,
)
# address is tagged by the measure class
@parameterized.expand(parse_test_case_file('en/data_text_normalization/test_cases_punctuation.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_en.normalize(test_input, verbose=False, punct_post_process=False)
assert pred == expected, f"input: {test_input} != {expected}"
@parameterized.expand(parse_test_case_file('en/data_text_normalization/test_cases_punctuation_match_input.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm_python_punct_post_process(self, test_input, expected):
pred = self.normalizer_en.normalize(test_input, verbose=True, punct_post_process=True)
assert pred == expected, f"for input |{test_input}|: pred: |{pred}| != expected: |{expected}|"
| NeMo-text-processing-main | tests/nemo_text_processing/en/test_punctuation.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestSerial:
normalizer_en = Normalizer(input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio_en = (
NormalizerWithAudio(input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
if RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('en/data_text_normalization/test_cases_serial.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_en.normalize(test_input, verbose=False, punct_post_process=False)
assert pred == expected, f"input: {test_input}"
if self.normalizer_with_audio_en:
pred_non_deterministic = self.normalizer_with_audio_en.normalize(
test_input, n_tagged=-1, punct_post_process=False,
)
assert expected in pred_non_deterministic, f"input: {test_input}"
| NeMo-text-processing-main | tests/nemo_text_processing/en/test_serial.py |
# Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestAddress:
normalizer_en = Normalizer(
input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False, post_process=True
)
normalizer_with_audio_en = (
NormalizerWithAudio(input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
if RUN_AUDIO_BASED_TESTS
else None
)
# address is tagged by the measure class
@parameterized.expand(parse_test_case_file('en/data_text_normalization/test_cases_address.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_en.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio_en:
pred_non_deterministic = self.normalizer_with_audio_en.normalize(
test_input, n_tagged=30, punct_post_process=False,
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/en/test_address.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestMeasure:
inverse_normalizer_en = InverseNormalizer(lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
inverse_normalizer_en_cased = InverseNormalizer(
lang='en', cache_dir=CACHE_DIR, overwrite_cache=False, input_case="cased"
)
@parameterized.expand(parse_test_case_file('en/data_inverse_text_normalization/test_cases_measure.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer_en.inverse_normalize(test_input, verbose=False)
assert pred == expected
pred = self.inverse_normalizer_en_cased.inverse_normalize(test_input, verbose=False)
assert pred == expected
@parameterized.expand(parse_test_case_file('en/data_inverse_text_normalization/test_cases_measure_cased.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer_en_cased.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer_en = Normalizer(input_case="cased", cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio_en = (
NormalizerWithAudio(input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
if RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('en/data_text_normalization/test_cases_measure.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_en.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio_en:
pred_non_deterministic = self.normalizer_with_audio_en.normalize(
test_input, n_tagged=30, punct_post_process=False,
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/en/test_measure.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestTime:
inverse_normalizer_en = InverseNormalizer(lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
inverse_normalizer_en_cased = InverseNormalizer(
lang='en', cache_dir=CACHE_DIR, overwrite_cache=False, input_case="cased"
)
@parameterized.expand(parse_test_case_file('en/data_inverse_text_normalization/test_cases_time.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer_en.inverse_normalize(test_input, verbose=False)
assert pred == expected
pred = self.inverse_normalizer_en_cased.inverse_normalize(test_input, verbose=False)
assert pred == expected
@parameterized.expand(parse_test_case_file('en/data_inverse_text_normalization/test_cases_time_cased.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer_en_cased.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer_en = Normalizer(input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio_en = (
NormalizerWithAudio(input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
if RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('en/data_text_normalization/test_cases_time.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_en.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio_en:
pred_non_deterministic = self.normalizer_with_audio_en.normalize(
test_input, n_tagged=10, punct_post_process=False
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/en/test_time.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestDecimal:
inverse_normalizer_en = InverseNormalizer(lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
inverse_normalizer_en_cased = InverseNormalizer(
lang='en', cache_dir=CACHE_DIR, overwrite_cache=False, input_case="cased"
)
@parameterized.expand(parse_test_case_file('en/data_inverse_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer_en.inverse_normalize(test_input, verbose=False)
assert pred == expected
pred = self.inverse_normalizer_en_cased.inverse_normalize(test_input, verbose=False)
assert pred == expected
@parameterized.expand(parse_test_case_file('en/data_inverse_text_normalization/test_cases_decimal_cased.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
pred = self.inverse_normalizer_en_cased.inverse_normalize(test_input, verbose=False)
assert pred == expected
normalizer_en = Normalizer(input_case="cased", cache_dir=CACHE_DIR, overwrite_cache=False, post_process=True)
normalizer_with_audio_en = (
NormalizerWithAudio(input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
if RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('en/data_text_normalization/test_cases_decimal.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_en.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio_en:
pred_non_deterministic = self.normalizer_with_audio_en.normalize(
test_input, n_tagged=30, punct_post_process=False,
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/en/test_decimal.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, get_test_cases_multiple
class TestNormalizeWithAudio:
normalizer_with_audio_en = NormalizerWithAudio(
input_case='cased', lang='en', lm=False, cache_dir=CACHE_DIR, overwrite_cache=False
)
@parameterized.expand(get_test_cases_multiple('en/data_text_normalization/test_cases_normalize_with_audio.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
if self.normalizer_with_audio_en:
pred = self.normalizer_with_audio_en.normalize(test_input, n_tagged=50, punct_post_process=True)
assert len(set(pred).intersection(set(expected))) == len(
expected
), f'missing: {set(expected).difference(set(pred))}'
| NeMo-text-processing-main | tests/nemo_text_processing/en/test_normalization_with_audio.py |
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from nemo_text_processing.text_normalization.normalize import Normalizer
from nemo_text_processing.text_normalization.normalize_with_audio import NormalizerWithAudio
from parameterized import parameterized
from ..utils import CACHE_DIR, RUN_AUDIO_BASED_TESTS, parse_test_case_file
class TestFraction:
normalizer_en = Normalizer(input_case="cased", cache_dir=CACHE_DIR, overwrite_cache=False)
normalizer_with_audio_en = (
NormalizerWithAudio(input_case='cased', lang='en', cache_dir=CACHE_DIR, overwrite_cache=False)
if RUN_AUDIO_BASED_TESTS
else None
)
@parameterized.expand(parse_test_case_file('en/data_text_normalization/test_cases_fraction.txt'))
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_norm(self, test_input, expected):
pred = self.normalizer_en.normalize(test_input, verbose=False)
assert pred == expected
if self.normalizer_with_audio_en:
pred_non_deterministic = self.normalizer_with_audio_en.normalize(
test_input, n_tagged=30, punct_post_process=False,
)
assert expected in pred_non_deterministic
| NeMo-text-processing-main | tests/nemo_text_processing/en/test_fraction.py |
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
| NeMo-text-processing-main | tests/nemo_text_processing/en/__init__.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.