-
Notifications
You must be signed in to change notification settings - Fork 185
Hi TN: Add support for Math normalization #486
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
Open
shrpawar-alt
wants to merge
6
commits into
NVIDIA:staging/hi_tn_v4
Choose a base branch
from
shrpawar-alt:hi-tn-math
base: staging/hi_tn_v4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f859ee4
math datatype added
shrpawar-alt 7796efc
jenkinsfile data update
shrpawar-alt 4b93c59
Merge branch 'staging/hi_tn_v4' into hi-tn-math
shrpawar-alt 626a2ac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 34f00ab
test case
shrpawar-alt ed1a91c
added math in SH tests
shrpawar-alt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
nemo_text_processing/text_normalization/hi/data/measure/math_operation.tsv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| + प्लस | ||
| - माइनस | ||
| / बटा | ||
| ÷ बटा | ||
| : बटा | ||
| × गुणा | ||
| * गुणा | ||
| · गुणा | ||
| = बराबर |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/nemo_text_processing/hi/data_text_normalization/test_cases_math.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 1-2=5~एक माइनस दो बराबर पाँच | ||
| 1- 2 = 5~एक माइनस दो बराबर पाँच | ||
| y=x +1~वाई बराबर एक्स प्लस एक | ||
| x +1 = y~एक्स प्लस एक बराबर वाई | ||
| १-२=५~एक माइनस दो बराबर पाँच | ||
| १- २ = ५~एक माइनस दो बराबर पाँच | ||
| y=x +१~वाई बराबर एक्स प्लस एक | ||
| x +१ = y~एक्स प्लस एक बराबर वाई | ||
| २ + २ = ४~दो प्लस दो बराबर चार | ||
| ७ + ३ = १०~सात प्लस तीन बराबर दस | ||
| १५ + ५ = २०~पंद्रह प्लस पाँच बराबर बीस | ||
| ५ - ३ = २~पाँच माइनस तीन बराबर दो | ||
| २० - ८ = १२~बीस माइनस आठ बराबर बारह | ||
| २ * ३ = ६~दो गुणा तीन बराबर छह | ||
| ४ * ५ = २०~चार गुणा पाँच बराबर बीस | ||
| ९ * ३ = २७~नौ गुणा तीन बराबर सत्ताईस | ||
| ६ / २ = ३~छह बटा दो बराबर तीन | ||
| १०० / ४ = २५~एक सौ बटा चार बराबर पच्चीस | ||
| २ + ३ + ४ = ९~दो प्लस तीन प्लस चार बराबर नौ | ||
| १० - २ - ३ = ५~दस माइनस दो माइनस तीन बराबर पाँच | ||
| ४ = २ + २~चार बराबर दो प्लस दो | ||
| 100 + 50 = 150~एक सौ प्लस पचास बराबर एक सौ पचास | ||
| 1-2+5/3*4=5.66666666667~एक माइनस दो प्लस पाँच बटा तीन गुणा चार बराबर पाँच दशमलव छह छह छह छह छह छह छह छह छह छह सात |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Copyright (c) 2026, 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 nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer | ||
| from nemo_text_processing.text_normalization.normalize import Normalizer | ||
|
|
||
| from ..utils import CACHE_DIR, parse_test_case_file | ||
|
|
||
|
|
||
| class TestMath: | ||
| normalizer = Normalizer( | ||
| input_case='cased', lang='hi', cache_dir=CACHE_DIR, overwrite_cache=True, post_process=False | ||
| ) | ||
| inverse_normalizer = InverseNormalizer(lang='hi', cache_dir=CACHE_DIR, overwrite_cache=False) | ||
|
|
||
| @parameterized.expand(parse_test_case_file('hi/data_text_normalization/test_cases_math.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.strip() == expected.strip() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's also add these to SH tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done