Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[G2P] fixed typos and broken import library. #5979

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nemo_text_processing/g2p/data/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"GRAPHEME_CASE_UPPER",
"GRAPHEME_CASE_LOWER",
"GRAPHEME_CASE_MIXED",
"get_heteronym_spans",
]

# Derived from LJSpeech
Expand Down
17 changes: 9 additions & 8 deletions tests/nemo_text_processing/g2p/data/test_data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from nemo_text_processing.g2p.data.data_utils import (
any_locale_word_tokenize,
english_word_tokenize,
get_homograph_spans,
get_heteronym_spans,
)


Expand Down Expand Up @@ -95,7 +95,7 @@ def test_any_locale_word_tokenize_with_accents(self):
@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_any_locale_word_tokenize_with_numbers(self):
input_text = "Three times× four^teen ÷divided by [movies] on \slash."
input_text = r"Three times× four^teen ÷divided by [movies] on \slash."
expected_output = self._create_expected_output(
[
"three",
Expand Down Expand Up @@ -124,10 +124,11 @@ def test_any_locale_word_tokenize_with_numbers(self):

@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_get_homograph_spans(self):
supported_homographs = ["live", "read", "protest", "diffuse", "desert"]
def test_get_heteronym_spans(self):
supported_heteronyms = ["live", "read", "protest", "diffuse", "desert"]
sentences = [
"I live in California. I READ a book. Only people who have already gained something are willing to protest. He reads a book!",
"I live in California. I READ a book. Only people who have already gained something are willing to protest."
" He reads a book!",
"Yesterday, I read a book.",
"He read a book last night and pre-diffuse and LivE-post and pre-desert-post.",
"the soldier deserted the desert in desert.",
Expand All @@ -139,13 +140,13 @@ def test_get_homograph_spans(self):
[(3, 7), (34, 41), (46, 50), (64, 70)],
[(25, 31), (35, 41)],
]
expected_homographs = [
expected_heteronyms = [
["live", "read", "protest"],
['read'],
['read', 'diffuse', 'live', 'desert'],
['desert', 'desert'],
]

out_start_end, out_homographs = get_homograph_spans(sentences, supported_homographs)
out_start_end, out_heteronyms = get_heteronym_spans(sentences, supported_heteronyms)
assert out_start_end == expected_start_end, "start-end spans do not match"
assert out_homographs == expected_homographs, "homograph spans do not match"
assert out_heteronyms == expected_heteronyms, "heteronym spans do not match"