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

Fix space issue with ZH ITN #244

Merged
merged 3 commits into from
Dec 10, 2024
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
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pipeline {
RU_TN_CACHE='/home/jenkinsci/TestData/text_norm/ci/grammars/06-08-23-0'
VI_TN_CACHE='/home/jenkinsci/TestData/text_norm/ci/grammars/06-08-23-0'
SV_TN_CACHE='/home/jenkinsci/TestData/text_norm/ci/grammars/06-08-23-0'
ZH_TN_CACHE='/home/jenkinsci/TestData/text_norm/ci/grammars/04-30-24-0'
ZH_TN_CACHE='/home/jenkinsci/TestData/text_norm/ci/grammars/11-13-24-0'
IT_TN_CACHE='/home/jenkinsci/TestData/text_norm/ci/grammars/08-22-24-0'
HY_TN_CACHE='/home/jenkinsci/TestData/text_norm/ci/grammars/03-12-24-0'
MR_TN_CACHE='/home/jenkinsci/TestData/text_norm/ci/grammars/03-12-24-1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
GraphFst,
delete_extra_space,
delete_space,
delete_zero_or_one_space,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a singular delete space that we can just use a kleene question with?

generator_main,
)
from nemo_text_processing.inverse_text_normalization.zh.taggers.cardinal import CardinalFst
Expand Down Expand Up @@ -92,12 +93,12 @@ def __init__(
)

punct = pynutil.insert("tokens { ") + pynutil.add_weight(punct_graph, weight=1.1) + pynutil.insert(" }")
token = pynutil.insert("tokens { ") + classify + pynutil.insert(" }")
token = pynutil.insert("tokens { ") + classify + pynutil.insert(" } ")
token_plus_punct = (
pynini.closure(punct + pynutil.insert(" ")) + token + pynini.closure(pynutil.insert(" ") + punct)
)

graph = token_plus_punct + pynini.closure(delete_extra_space + token_plus_punct)
graph = token_plus_punct + pynini.closure(delete_zero_or_one_space + token_plus_punct)
graph = delete_space + graph + delete_space

self.fst = graph.optimize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class WordFst(GraphFst):

def __init__(self):
super().__init__(name="word", kind="classify")
word = pynutil.insert('name: "') + pynini.closure(NEMO_NOT_SPACE, 1) + pynutil.insert('"')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remind me on this syntax, is the closure(...,1) equivalent to 0 or 1 or match exactly one?

word = pynutil.insert('name: "') + NEMO_NOT_SPACE + pynutil.insert('"')
self.fst = word.optimize()
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ def __init__(self):
+ delete_space
+ pynutil.delete("}")
)
graph = delete_space + pynini.closure(graph + delete_extra_space) + graph + delete_space
graph = delete_space + pynini.closure(graph + delete_space) + graph + delete_space
self.fst = graph
Loading