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

punct process bug fix #3747

Merged
merged 2 commits into from
Feb 24, 2022
Merged
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
8 changes: 4 additions & 4 deletions nemo/collections/nlp/data/text_normalization/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ def post_process_punct(input: str, normalized_text: str):
punct_default = [x for x in string.punctuation]
punct_unicode = [chr(i) for i in range(sys.maxunicode) if category(chr(i)).startswith("P")]
punct_marks = set(punct_default + punct_unicode)
try:
for punct in punct_marks:
for punct in punct_marks:
try:
equal = True
if input.count(punct) != normalized_text.count(punct):
equal = False
Expand Down Expand Up @@ -253,8 +253,8 @@ def _is_valid(idx_out, idx_in, normalized_text, input):
normalized_text[idx_out] = normalized_text[idx_out] + " "
idx_out += 1
idx_in += 1
except:
logging.debug(f"Skipping post-processing of {''.join(normalized_text)} for '{punct}'")
except:
logging.debug(f"Skipping post-processing of {''.join(normalized_text)} for '{punct}'")

normalized_text = "".join(normalized_text)
return re.sub(r' +', ' ', normalized_text)