Skip to content

fix: remove duplicated standalone-year acceptor definitions - #473

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/date-remove-duplicated-standalone-year
Open

fix: remove duplicated standalone-year acceptor definitions#473
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/date-remove-duplicated-standalone-year

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

This PR addresses the following issue in nemo_text_processing/text_normalization/ko/taggers/date.py: remove duplicated standalone-year acceptor definitions.

Changes

  • nemo_text_processing/text_normalization/ko/taggers/date.py: remove duplicated standalone-year acceptor definitions.

Details

--- a/nemo_text_processing/text_normalization/ko/taggers/date.py
+++ b/nemo_text_processing/text_normalization/ko/taggers/date.py
@@ -1,5 +1,2 @@
-        # For standalone years:
-        # - No era: 1–4 digits with NO leading zeros
-        YEAR_NO_ERA_1TO4 = pynini.closure(pynutil.delete("0"), 0, 3) + _1to9 + pynini.closure(_d, 0, 3)
-        # - With era (기원전/기원후): allow leading zeros but strip them
-        YEAR_ERA_1TO4 = pynini.closure(pynutil.delete("0"), 0, 3) + _1to9 + pynini.closure(_d, 0, 3)
+        # Standalone year acceptor: 1-4 digits with leading zeros stripped.
+        YEAR_1TO4 = pynini.closure(pynutil.delete("0"), 0, 3) + _1to9 + pynini.closure(_d, 0, 3)

Tests

  • tests/nemo_text_processing/ko/test_date.py
--- a/tests/nemo_text_processing/ko/test_date.py
+++ b/tests/nemo_text_processing/ko/test_date.py
@@ -XX,XX +XX,XX @@ class TestDate:
         """
         self._run_test(input_text, expected)
 
+    @pytest.mark.run(after="test_date")
+    def test_standalone_year_no_era(self):
+        input_text = "2024년"
+        expected = 'date { year: "이천이십사년" }'
+        self._run_test(input_text, expected)
+
+    @pytest.mark.run(after="test_date")
+    def test_standalone_year_with_era(self):
+        input_text = "기원전233년"
+        expected = 'date { era: "기원전" year: "이백삼십삼년" }'
+        self._run_test(input_text, expected)
+
+    @pytest.mark.run(after="test_date")
+    def test_standalone_year_leading_zeros_stripped(self):
+        input_text = "기원후0024년"
+        expected = 'date { era: "기원후" year: "이십사년" }'
+        self._run_test(input_text, expected)
+
     def _run_test(self, input_text, expected):
         print("input_text: ", input_text)
         pred = self.tagger(input_text)

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

@github-actions github-actions Bot added the Stale label Sep 1, 2026
Signed-off-by: andrewwhitecdw <andrewwhitecdw@users.noreply.github.com>
@andrewwhitecdw
andrewwhitecdw force-pushed the codequality/date-remove-duplicated-standalone-year branch from 76077b8 to fcf7123 Compare September 2, 2026 19:36
@github-actions github-actions Bot removed the Stale label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant