gladia-normalization 0.1.0a5__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. gladia_normalization-0.2.0/.github/pull_request_template.md +76 -0
  2. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/.github/workflows/cd.yml +1 -2
  3. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/.github/workflows/ci.yml +1 -1
  4. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/.gitignore +1 -0
  5. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/AGENTS.md +1 -1
  6. gladia_normalization-0.2.0/CONTRIBUTING.md +86 -0
  7. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/PKG-INFO +36 -6
  8. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/README.md +34 -5
  9. gladia_normalization-0.2.0/docs/contributing-guide.md +211 -0
  10. gladia_normalization-0.2.0/normalization/__main__.py +3 -0
  11. gladia_normalization-0.2.0/normalization/cli.py +88 -0
  12. gladia_normalization-0.2.0/normalization/languages/__init__.py +15 -0
  13. gladia_normalization-0.2.0/normalization/languages/dutch/__init__.py +7 -0
  14. gladia_normalization-0.2.0/normalization/languages/dutch/number_normalizer.py +144 -0
  15. gladia_normalization-0.2.0/normalization/languages/dutch/operators.py +160 -0
  16. gladia_normalization-0.2.0/normalization/languages/dutch/replacements.py +28 -0
  17. gladia_normalization-0.2.0/normalization/languages/dutch/sentence_replacements.py +9 -0
  18. gladia_normalization-0.2.0/normalization/languages/french/number_normalizer.py +72 -0
  19. gladia_normalization-0.2.0/normalization/languages/french/operators.py +138 -0
  20. gladia_normalization-0.2.0/normalization/languages/french/replacements.py +28 -0
  21. gladia_normalization-0.2.0/normalization/languages/french/sentence_replacements.py +13 -0
  22. gladia_normalization-0.2.0/normalization/languages/german/__init__.py +7 -0
  23. gladia_normalization-0.2.0/normalization/languages/german/number_normalizer.py +67 -0
  24. gladia_normalization-0.2.0/normalization/languages/german/operators.py +93 -0
  25. gladia_normalization-0.2.0/normalization/languages/german/replacements.py +10 -0
  26. gladia_normalization-0.2.0/normalization/languages/german/sentence_replacements.py +16 -0
  27. gladia_normalization-0.2.0/normalization/languages/italian/__init__.py +7 -0
  28. gladia_normalization-0.2.0/normalization/languages/italian/number_normalizer.py +58 -0
  29. gladia_normalization-0.2.0/normalization/languages/italian/operators.py +109 -0
  30. gladia_normalization-0.2.0/normalization/languages/italian/replacements.py +11 -0
  31. gladia_normalization-0.2.0/normalization/languages/italian/sentence_replacements.py +3 -0
  32. gladia_normalization-0.2.0/normalization/languages/spanish/__init__.py +7 -0
  33. gladia_normalization-0.2.0/normalization/languages/spanish/number_normalizer.py +196 -0
  34. gladia_normalization-0.2.0/normalization/languages/spanish/operators.py +139 -0
  35. gladia_normalization-0.2.0/normalization/languages/spanish/replacements.py +30 -0
  36. gladia_normalization-0.2.0/normalization/pipeline/replacer.py +53 -0
  37. gladia_normalization-0.2.0/normalization/steps/text/convert_word_based_time_patterns.py +147 -0
  38. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/pyproject.toml +12 -2
  39. gladia_normalization-0.2.0/tests/e2e/files/gladia-3/de.csv +45 -0
  40. gladia_normalization-0.2.0/tests/e2e/files/gladia-3/default.csv +11 -0
  41. gladia_normalization-0.2.0/tests/e2e/files/gladia-3/en.csv +132 -0
  42. gladia_normalization-0.2.0/tests/e2e/files/gladia-3/es.csv +38 -0
  43. gladia_normalization-0.2.0/tests/e2e/files/gladia-3/fr.csv +54 -0
  44. gladia_normalization-0.2.0/tests/e2e/files/gladia-3/it.csv +72 -0
  45. gladia_normalization-0.2.0/tests/e2e/files/gladia-3/nl.csv +35 -0
  46. gladia_normalization-0.2.0/tests/e2e/latency_test.py +32 -0
  47. gladia_normalization-0.2.0/tests/e2e/normalization_test.py +90 -0
  48. gladia_normalization-0.2.0/tests/unit/languages/dutch_number_normalizer_test.py +68 -0
  49. gladia_normalization-0.2.0/tests/unit/languages/dutch_operators_test.py +51 -0
  50. gladia_normalization-0.2.0/tests/unit/steps/text/apply_sentence_level_replacements_test.py +18 -0
  51. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/text/conftest.py +12 -0
  52. gladia_normalization-0.2.0/tests/unit/steps/text/convert_word_based_time_patterns_test.py +67 -0
  53. gladia_normalization-0.2.0/tests/unit/steps/text/expand_contractions_test.py +21 -0
  54. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/uv.lock +97 -1
  55. gladia_normalization-0.1.0a5/.github/pull_request_template.md +0 -43
  56. gladia_normalization-0.1.0a5/CONTRIBUTING.md +0 -217
  57. gladia_normalization-0.1.0a5/normalization/languages/__init__.py +0 -7
  58. gladia_normalization-0.1.0a5/normalization/languages/french/operators.py +0 -38
  59. gladia_normalization-0.1.0a5/normalization/languages/french/replacements.py +0 -1
  60. gladia_normalization-0.1.0a5/normalization/pipeline/replacer.py +0 -38
  61. gladia_normalization-0.1.0a5/normalization/steps/text/convert_word_based_time_patterns.py +0 -70
  62. gladia_normalization-0.1.0a5/tests/e2e/files/gladia-3.csv +0 -126
  63. gladia_normalization-0.1.0a5/tests/e2e/normalization_test.py +0 -68
  64. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/.commitlintrc.json +0 -0
  65. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/.pre-commit-config.yaml +0 -0
  66. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/.python-version +0 -0
  67. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/CLAUDE.md +0 -0
  68. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/LICENSE +0 -0
  69. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/docs/steps.md +0 -0
  70. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/__init__.py +0 -0
  71. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/constants/__init__.py +0 -0
  72. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/constants/protectors.py +0 -0
  73. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/languages/base/__init__.py +0 -0
  74. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/languages/base/language_config.py +0 -0
  75. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/languages/base/language_operator.py +0 -0
  76. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/languages/english/__init__.py +0 -0
  77. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/languages/english/number_normalizer.py +0 -0
  78. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/languages/english/operators.py +0 -0
  79. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/languages/english/replacements.py +0 -0
  80. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/languages/english/sentence_replacements.py +0 -0
  81. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/languages/french/__init__.py +0 -0
  82. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/languages/registry.py +0 -0
  83. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/pipeline/__init__.py +0 -0
  84. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/pipeline/base.py +0 -0
  85. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/pipeline/loader.py +0 -0
  86. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/presets/gladia-3.yaml +0 -0
  87. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/__init__.py +0 -0
  88. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/base/__init__.py +0 -0
  89. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/base/protect_step.py +0 -0
  90. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/base/restore_step.py +0 -0
  91. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/base/text_step.py +0 -0
  92. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/base/word_step.py +0 -0
  93. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/registry.py +0 -0
  94. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/__init__.py +0 -0
  95. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/apply_sentence_level_replacements.py +0 -0
  96. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/casefold_text.py +0 -0
  97. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/convert_comparison_operators_to_words.py +0 -0
  98. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/convert_decimal_periods_to_decimal_word.py +0 -0
  99. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/convert_degree_symbols_to_words.py +0 -0
  100. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/convert_digit_word_sequences_to_digits.py +0 -0
  101. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/convert_dots_to_words_in_technical_contexts.py +0 -0
  102. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/convert_oclock_to_numeric_time.py +0 -0
  103. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/convert_roman_numerals_to_digits.py +0 -0
  104. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/expand_alphanumeric_codes.py +0 -0
  105. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/expand_contractions.py +0 -0
  106. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/expand_written_numbers_to_digits.py +0 -0
  107. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/expand_www_abbreviation.py +0 -0
  108. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/fix_ampm_letter_spacing.py +0 -0
  109. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/fix_dot_adjacent_number_words.py +0 -0
  110. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/fix_one_word_in_numeric_contexts.py +0 -0
  111. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/fix_version_number_v_prefix.py +0 -0
  112. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/format_time_patterns_with_ampm.py +0 -0
  113. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/normalize_numeric_time_formats.py +0 -0
  114. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/normalize_punctuation_between_number_words.py +0 -0
  115. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/placeholders.py +0 -0
  116. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/protect_plus_word_before_digit_words.py +0 -0
  117. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_acronym_periods.py +0 -0
  118. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_diacritics.py +0 -0
  119. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_filler_words.py +0 -0
  120. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_hash_before_numbers.py +0 -0
  121. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_non_numeric_trailing_dots.py +0 -0
  122. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_spaces_between_adjacent_digits.py +0 -0
  123. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_standalone_currency_symbols.py +0 -0
  124. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_symbols.py +0 -0
  125. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_thousand_separators.py +0 -0
  126. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_trailing_apostrophe_space.py +0 -0
  127. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_trailing_dot_word_from_emails.py +0 -0
  128. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_trailing_period.py +0 -0
  129. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/remove_zero_minutes_from_time.py +0 -0
  130. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/text/replace_currency.py +0 -0
  131. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/word/__init__.py +0 -0
  132. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/normalization/steps/word/apply_word_replacements.py +0 -0
  133. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/scripts/generate_step_docs.py +0 -0
  134. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/__init__.py +0 -0
  135. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/e2e/__init__.py +0 -0
  136. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/e2e/default_pipeline_test.py +0 -0
  137. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/languages/__init__.py +0 -0
  138. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/languages/english_registry_test.py +0 -0
  139. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/languages/symbols_to_words_test.py +0 -0
  140. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/languages/word_replacement_test.py +0 -0
  141. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/__init__.py +0 -0
  142. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/text/__init__.py +0 -0
  143. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/text/convert_dots_to_words_in_technical_contexts_test.py +0 -0
  144. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/text/convert_oclock_to_numeric_time_test.py +0 -0
  145. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/text/convert_roman_numerals_to_digits_test.py +0 -0
  146. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/text/protect_decimal_separator_test.py +0 -0
  147. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/text/remove_diacritics_test.py +0 -0
  148. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/text/remove_zero_minutes_from_time_test.py +0 -0
  149. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/text/replace_currency_test.py +0 -0
  150. {gladia_normalization-0.1.0a5 → gladia_normalization-0.2.0}/tests/unit/steps/text/restore_decimal_separator_with_word_test.py +0 -0
@@ -0,0 +1,76 @@
1
+ ## What does this PR do?
2
+
3
+ <!-- One sentence: what changed and why. -->
4
+
5
+ ## Type of change
6
+
7
+ - [ ] New language
8
+ - [ ] Edit existing language (fix a replacement, tweak config, …)
9
+ - [ ] New normalization step
10
+ - [ ] Edit existing step (bug fix, behaviour change)
11
+ - [ ] New preset version
12
+ - [ ] Bug fix (other)
13
+ - [ ] Refactor / docs / CI
14
+
15
+ ---
16
+
17
+ ## Checklist
18
+
19
+ **Only fill in the section(s) that match your change — delete the rest.**
20
+
21
+ ---
22
+
23
+ ### New language
24
+
25
+ - [ ] Created `normalization/languages/{lang}/` with `operators.py`, `replacements.py`, `__init__.py`
26
+ - [ ] Word substitutions are in `replacements.py` (not hardcoded in `operators.py`)
27
+ - [ ] `LanguageConfig` is filled in with the language's data (separators, currency words, digit words, …)
28
+ - [ ] Subclassed `LanguageOperators` — only override methods where the **logic** changes, not just the data
29
+ - [ ] Class is decorated with `@register_language` and imported in `normalization/languages/__init__.py`
30
+ - [ ] Unit tests added in `tests/unit/languages/`
31
+ - [ ] E2e CSV added in `tests/e2e/files/{preset}/{lang}.csv` (e.g. `tests/e2e/files/gladia-3/fr.csv`)
32
+
33
+ ---
34
+
35
+ ### Edit existing language
36
+
37
+ - [ ] New/changed word substitutions go in `replacements.py`, not inline in `operators.py`
38
+ - [ ] If you changed a config field that can be `None`: the step reading it still handles `None` gracefully
39
+ - [ ] Unit tests updated or added
40
+ - [ ] E2e CSV updated if the expected output changed
41
+
42
+ ---
43
+
44
+ ### New step
45
+
46
+ - [ ] Unique `name` class attribute set (this is the key used in YAML presets)
47
+ - [ ] Decorated with `@register_step` and imported in `steps/text/__init__.py` or `steps/word/__init__.py`
48
+ - [ ] No hardcoded language values — read data from `operators.config.*` instead
49
+ - [ ] If placeholder-based: protect + restore are both in `steps/text/placeholders.py` and `pipeline/base.py`'s `validate()` is updated
50
+ - [ ] Unit tests added in `tests/unit/steps/`
51
+ - [ ] Step name added to the relevant preset YAML — or a **new preset file** created if existing presets are affected
52
+ - [ ] If the docstring changed: ran `uv run scripts/generate_step_docs.py`
53
+
54
+ ---
55
+
56
+ ### Edit existing step
57
+
58
+ - [ ] Step `name` is unchanged — if the output changes, create a new step name + new preset instead
59
+ - [ ] No language-specific logic or string literals added inside the step
60
+ - [ ] Unit tests updated or added
61
+ - [ ] If the docstring changed: ran `uv run scripts/generate_step_docs.py`
62
+
63
+ ---
64
+
65
+ ### Preset change
66
+
67
+ - [ ] Existing preset files are **not modified** — new behaviour goes in a new preset file
68
+ - [ ] `pipeline.validate()` passes (runs automatically via `loader.py`)
69
+
70
+ ---
71
+
72
+ ## How was this tested?
73
+
74
+ ```
75
+ uv run pytest tests/
76
+ ```
@@ -40,8 +40,7 @@ jobs:
40
40
  run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
41
41
 
42
42
  - name: Update version in pyproject.toml
43
- run: |
44
- uv version ${{ steps.version.outputs.version }}
43
+ run: uv version ${{ steps.version.outputs.version }}
45
44
 
46
45
  - name: Build
47
46
  run: uv build
@@ -46,7 +46,7 @@ jobs:
46
46
  runs-on: ubuntu-latest
47
47
  strategy:
48
48
  matrix:
49
- python-version: ["3.10", "3.11", "3.12", "3.13"]
49
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
50
50
  steps:
51
51
  - uses: actions/checkout@v6
52
52
  - uses: astral-sh/setup-uv@v7
@@ -7,6 +7,7 @@ wheels/
7
7
  *.egg-info
8
8
  .ruff_cache/
9
9
  .pytest_cache/
10
+ .DS_Store
10
11
 
11
12
 
12
13
  # Virtual environments
@@ -144,7 +144,7 @@ Never modify a published preset YAML. Never let a preset reference a step that h
144
144
  - [ ] Decorate the class with `@register_language`
145
145
  - [ ] Add one import to `languages/__init__.py`
146
146
  - [ ] Add tests in `tests/unit/languages/`
147
- - [ ] Add test rows to `tests/e2e/files/` for the new language
147
+ - [ ] Add a CSV file `tests/e2e/files/{preset}/{language_code}.csv` for each relevant preset (e.g. `tests/e2e/files/gladia-3/fr.csv`)
148
148
 
149
149
  ## Adding a new step — checklist
150
150
 
@@ -0,0 +1,86 @@
1
+ # Contributing to gladia-normalization
2
+
3
+ Thanks for your interest in contributing! Every contribution — whether it's a new language, a normalization step, or a bug report — makes the library more useful for the entire voice AI community.
4
+
5
+ ## Code of conduct
6
+
7
+ Please be respectful and welcoming in all interactions. We're committed to making this a safe and inclusive space for everyone. If you experience or witness unacceptable behavior, please open a GitHub issue or contact the maintainers directly.
8
+
9
+ ## How you can help
10
+
11
+ ### Add support for a new language
12
+
13
+ This is the most impactful contribution. We don't master every language — and that's exactly where the community can make a difference. If you speak a language not yet supported, you can add it in a self-contained folder with no changes to the core pipeline.
14
+
15
+ A new language requires:
16
+
17
+ 1. Create `normalization/languages/{lang}/` with `operators.py`, `replacements.py`, and `__init__.py`
18
+ 2. Put all word-level substitutions in `replacements.py`
19
+ 3. Instantiate a `LanguageConfig` and subclass `LanguageOperators` in `operators.py`
20
+ 4. Decorate with `@register_language` and add one import to `normalization/languages/__init__.py`
21
+ 5. Add tests under `tests/unit/languages/` and a per-language CSV in `tests/e2e/files/{preset}/` (e.g. `tests/e2e/files/gladia-3/fr.csv`)
22
+
23
+ See [docs/contributing-guide.md](docs/contributing-guide.md) for the full checklist and design rules.
24
+
25
+ ### Add a new normalization step
26
+
27
+ Steps are atomic, stateless transformations that plug into the pipeline via a decorator — no manual registry updates needed.
28
+
29
+ A new step requires:
30
+
31
+ 1. Create or extend a file under `normalization/steps/text/` or `normalization/steps/word/`
32
+ 2. Decorate the class with `@register_step` and set a unique `name` attribute
33
+ 3. Add an import to `steps/text/__init__.py` or `steps/word/__init__.py`
34
+ 4. Add unit tests under `tests/unit/steps/`
35
+ 5. Add the step name to the relevant preset YAML, or create a new preset version
36
+ 6. If you added or changed the class docstring, regenerate `docs/steps.md`: `uv run scripts/generate_step_docs.py`
37
+
38
+ See [docs/contributing-guide.md](docs/contributing-guide.md) for base class selection and test conventions.
39
+
40
+ ### Report a bug
41
+
42
+ Open an issue with steps to reproduce, expected vs. actual behavior, and your environment (Python version, OS, package version).
43
+
44
+ ### Ask a question
45
+
46
+ Open a GitHub issue with the `question` label. We're happy to help.
47
+
48
+ ---
49
+
50
+ ## Development setup
51
+
52
+ ```bash
53
+ git clone https://github.com/gladiaio/normalization.git
54
+ cd normalization
55
+ uv sync
56
+ uv run pre-commit install --install-hooks # install hooks once
57
+ ```
58
+
59
+ Run the checks at any time:
60
+
61
+ ```bash
62
+ uv run pytest # run tests
63
+ uv run ruff check . # lint
64
+ uv run ruff format . # format
65
+ uv run ty check # type-check
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Submitting changes
71
+
72
+ 1. Fork the repo and create a branch: `git checkout -b feat/my-feature`
73
+ 2. Make your changes and add tests
74
+ 3. Run the checks (see above) and make sure everything passes
75
+ 4. Push your branch: `git push origin your-feature-branch`
76
+ 5. Open a pull request on GitHub with a clear description of your changes, filling the [template](./.github/pull_request_template.md)
77
+ 6. Address review feedback and push updates
78
+ 7. Once approved, your PR will be merged
79
+
80
+ ### Pre-commit hooks
81
+
82
+ The hooks run automatically on every commit: Ruff (lint + format), ty (type-check), and commit message validation. If a hook fails, fix the issue and commit again.
83
+
84
+ ## Commit style
85
+
86
+ We use [Conventional Commits](https://www.conventionalcommits.org/): prefix your commit with `feat:`, `fix:`, `docs:`, `chore:`, etc.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gladia-normalization
3
- Version: 0.1.0a5
3
+ Version: 0.2.0
4
4
  Summary: Normalize speech-to-text output for fair Word Error Rate (WER) comparison
5
5
  Project-URL: Homepage, https://github.com/gladiaio/normalization
6
6
  Project-URL: Repository, https://github.com/gladiaio/normalization
@@ -39,12 +39,13 @@ Classifier: Topic :: Text Processing :: Linguistic
39
39
  Requires-Python: >=3.10
40
40
  Requires-Dist: contractions>=0.1.73
41
41
  Requires-Dist: pyyaml>=6.0.3
42
+ Requires-Dist: text2num>=3.0.0
42
43
  Description-Content-Type: text/markdown
43
44
 
44
45
  <p align="center">
45
46
  <h1 align="center">Normalization</h1>
46
47
  <p align="center">
47
- Text normalization for fair speech-to-text evaluation.
48
+ A lightweight library for normalizing speech transcripts before computing WER.
48
49
  <br />
49
50
  <a href="#quick-start">Quick Start</a> &middot; <a href="docs/steps.md">Step Reference</a> &middot; <a href="CONTRIBUTING.md">Contributing</a>
50
51
  </p>
@@ -114,6 +115,31 @@ pipeline.normalize("It's $50 at 3:00PM")
114
115
  # => "it is 50 dollars at 3 pm"
115
116
  ```
116
117
 
118
+ ### CLI
119
+
120
+ ```bash
121
+ # Normalize a single text
122
+ gladia-normalization "A tea cost £2 at 3:30PM" --language en
123
+
124
+ # Normalize a text file
125
+ gladia-normalization --file transcript.txt --language en
126
+
127
+ # Pipe from stdin
128
+ echo "A tea cost £2 at 3:30PM" | gladia-normalization --language fr
129
+
130
+ # Use a custom preset
131
+ gladia-normalization "A tea cost £2 at 3:30PM" --preset path/to/my-preset.yaml --language en
132
+
133
+ # Inspect the pipeline
134
+ gladia-normalization --describe --language en
135
+ ```
136
+
137
+ If you don't want a permanent installation, run it directly with `uvx`:
138
+
139
+ ```bash
140
+ uvx gladia-normalization "A tea cost £2 at 3:30PM" --language en
141
+ ```
142
+
117
143
  ## How it works
118
144
 
119
145
  Every pipeline runs exactly **three stages**, always in this order:
@@ -128,10 +154,14 @@ Pipelines are defined declaratively in **YAML presets**. Each preset lists the s
128
154
 
129
155
  ## Supported languages
130
156
 
131
- | Code | Language |
132
- | ---- | -------------- |
133
- | `en` | English |
134
- | `fr` | French (alpha) |
157
+ | Code | Language |
158
+ | ---- | -------- |
159
+ | `en` | English |
160
+ | `fr` | French |
161
+ | `de` | German |
162
+ | `it` | Italian |
163
+ | `es` | Spanish |
164
+ | `nl` | Dutch |
135
165
 
136
166
  Unsupported language codes fall back to a safe default that applies language-independent normalization only.
137
167
 
@@ -1,7 +1,7 @@
1
1
  <p align="center">
2
2
  <h1 align="center">Normalization</h1>
3
3
  <p align="center">
4
- Text normalization for fair speech-to-text evaluation.
4
+ A lightweight library for normalizing speech transcripts before computing WER.
5
5
  <br />
6
6
  <a href="#quick-start">Quick Start</a> &middot; <a href="docs/steps.md">Step Reference</a> &middot; <a href="CONTRIBUTING.md">Contributing</a>
7
7
  </p>
@@ -71,6 +71,31 @@ pipeline.normalize("It's $50 at 3:00PM")
71
71
  # => "it is 50 dollars at 3 pm"
72
72
  ```
73
73
 
74
+ ### CLI
75
+
76
+ ```bash
77
+ # Normalize a single text
78
+ gladia-normalization "A tea cost £2 at 3:30PM" --language en
79
+
80
+ # Normalize a text file
81
+ gladia-normalization --file transcript.txt --language en
82
+
83
+ # Pipe from stdin
84
+ echo "A tea cost £2 at 3:30PM" | gladia-normalization --language fr
85
+
86
+ # Use a custom preset
87
+ gladia-normalization "A tea cost £2 at 3:30PM" --preset path/to/my-preset.yaml --language en
88
+
89
+ # Inspect the pipeline
90
+ gladia-normalization --describe --language en
91
+ ```
92
+
93
+ If you don't want a permanent installation, run it directly with `uvx`:
94
+
95
+ ```bash
96
+ uvx gladia-normalization "A tea cost £2 at 3:30PM" --language en
97
+ ```
98
+
74
99
  ## How it works
75
100
 
76
101
  Every pipeline runs exactly **three stages**, always in this order:
@@ -85,10 +110,14 @@ Pipelines are defined declaratively in **YAML presets**. Each preset lists the s
85
110
 
86
111
  ## Supported languages
87
112
 
88
- | Code | Language |
89
- | ---- | -------------- |
90
- | `en` | English |
91
- | `fr` | French (alpha) |
113
+ | Code | Language |
114
+ | ---- | -------- |
115
+ | `en` | English |
116
+ | `fr` | French |
117
+ | `de` | German |
118
+ | `it` | Italian |
119
+ | `es` | Spanish |
120
+ | `nl` | Dutch |
92
121
 
93
122
  Unsupported language codes fall back to a safe default that applies language-independent normalization only.
94
123
 
@@ -0,0 +1,211 @@
1
+ # Contributing guide
2
+
3
+ Detailed reference for contributors. Read this before adding a step or language.
4
+
5
+ ## Architecture at a glance
6
+
7
+ Every pipeline runs exactly **three stages**, always in this order:
8
+
9
+ 1. **Text pre-processing** — full-text transforms before word splitting (placeholder protection, symbol conversion, contraction expansion, …)
10
+ 2. **Word processing** — per-token transforms after splitting on spaces (replacements, filler removal, …)
11
+ 3. **Text post-processing** — full-text cleanup after rejoining words (placeholder restoration, digit collapsing, …)
12
+
13
+ This ordering is a hard constraint — some steps depend on earlier steps having run. See the [README](../README.md) for more detail.
14
+
15
+ ---
16
+
17
+ ## Adding a new language — checklist
18
+
19
+ - [ ] Create `languages/{lang}/` with `operators.py`, `replacements.py`, `__init__.py`
20
+ - [ ] Put all word-level substitutions in `replacements.py`; do not add inline entries in `operators.py`
21
+ - [ ] Instantiate a `LanguageConfig` in `operators.py`, filling in all required fields and any optional dict fields your language needs (`time_words`, `sentence_replacements`, etc.)
22
+ - [ ] Subclass `LanguageOperators`, overriding only methods where the _algorithm_ differs (not just the data)
23
+ - [ ] If the language has digit words, populate `digit_words` in `LanguageConfig`
24
+ - [ ] If the language uses spoken time patterns, populate `time_words` with all needed word→digit mappings; if it also uses compound minute expressions (e.g. "twenty-one"), override `get_compound_minutes()` — do **not** put this in config
25
+ - [ ] If number expansion is needed and the algorithm is complex, implement it in a `number_normalizer.py` file and override `expand_written_numbers`; otherwise do not create the file
26
+ - [ ] Decorate the class with `@register_language`
27
+ - [ ] Add one import to `languages/__init__.py`
28
+ - [ ] Add tests in `tests/unit/languages/`
29
+ - [ ] Add a CSV file `tests/e2e/files/{preset}/{language_code}.csv` for each relevant preset (e.g. `tests/e2e/files/gladia-3/fr.csv`)
30
+
31
+ ### Language data vs. language behavior
32
+
33
+ This is the central design rule. Ask: "does the _logic_ change by language, or just the _values_?"
34
+
35
+ **`LanguageConfig` (data)** — everything that can be expressed as a value: strings, lists, dicts. Separator characters, currency words, filler words, digit words, number words, time words, sentence replacements. Optional fields default to `None`; steps that read them skip gracefully when `None`.
36
+
37
+ **`LanguageOperators` (behavior)** — only methods where the _algorithm itself_ varies by language. Examples: `expand_contractions`, `expand_written_numbers`, `normalize_numeric_time_formats`, `get_compound_minutes`. If the algorithm is generic and only the _data_ differs, put the data in `LanguageConfig` and the algorithm in the step — not in the operator.
38
+
39
+ ---
40
+
41
+ ## Adding a new step — checklist
42
+
43
+ - [ ] Add the class to the appropriate file in `steps/text/` or `steps/word/`
44
+ - [ ] Set a unique `name` class attribute
45
+ - [ ] Decorate with `@register_step`
46
+ - [ ] Add one import to `steps/text/__init__.py` or `steps/word/__init__.py`
47
+ - [ ] Place the algorithm in `__call__`; read language data from `operators.config.*`; call operator methods only for genuinely behavioral differences
48
+ - [ ] If the step reads an optional `LanguageConfig` field, guard with `if operators.config.field is None: return text`
49
+ - [ ] Add unit tests in `tests/unit/steps/`
50
+ - [ ] If it involves placeholder protection, add both protect and restore to `steps/text/placeholders.py` and update `pipeline/base.py`'s `validate()` accordingly
51
+ - [ ] Add the step name to relevant preset YAMLs if needed (new preset version if existing presets are affected)
52
+ - [ ] If you added or changed the class docstring, run `uv run scripts/generate_step_docs.py` to regenerate `docs/steps.md`
53
+
54
+ ### Choosing a base class
55
+
56
+ Pick the narrowest one that fits your step.
57
+
58
+ **`WordStep`** — use when your transformation operates on a single token in isolation, with no knowledge of neighboring words. This is the only base class for Stage 2 steps.
59
+
60
+ ```python
61
+ @register_step
62
+ class MyWordStep(WordStep):
63
+ name = "my_word_step"
64
+
65
+ def __call__(self, word: str, operators: LanguageOperators) -> str:
66
+ ...
67
+ ```
68
+
69
+ **`TextStep`** — the general-purpose base for Stage 1 and Stage 3. Use it when your transformation needs to see the full string, or when none of the more specific bases below fit.
70
+
71
+ ```python
72
+ @register_step
73
+ class MyTextStep(TextStep):
74
+ name = "my_text_step"
75
+
76
+ def __call__(self, text: str, operators: LanguageOperators) -> str:
77
+ ...
78
+ ```
79
+
80
+ **`ProtectStep`** — a specialization of `TextStep` for replacing a character with a placeholder token. Implement `_pattern`, which returns a compiled regex with **exactly two capture groups** (what comes before and after the character being replaced). The `__call__` is fixed: it applies the pattern as `\1{placeholder}\2`.
81
+
82
+ ```python
83
+ @register_step
84
+ class MyProtectStep(ProtectStep):
85
+ name = "my_protect_step"
86
+ placeholder = ProtectPlaceholder.MY_PLACEHOLDER
87
+
88
+ def _pattern(self, operators: LanguageOperators) -> re.Pattern:
89
+ return re.compile(r"(\d+)X(\d+)") # two capture groups required
90
+ ```
91
+
92
+ Use `ProtectStep` when: one regex pattern maps to exactly one placeholder substitution.
93
+
94
+ Use `TextStep` directly instead when: a single pass must protect two different symbols, the replacement needs to absorb surrounding whitespace with `\s*`, or the replacement is a per-match function rather than a fixed template.
95
+
96
+ **`RestoreStep`** — a specialization of `TextStep` for restoring a placeholder back to a string. Implement `_replacement`, which returns the string to substitute in. The `__call__` does a plain `str.replace` of the placeholder (and its case-folded form).
97
+
98
+ ```python
99
+ @register_step
100
+ class MyRestoreStep(RestoreStep):
101
+ name = "my_restore_step"
102
+ placeholder = ProtectPlaceholder.MY_PLACEHOLDER
103
+
104
+ def _replacement(self, operators: LanguageOperators) -> str:
105
+ return operators.config.some_word or " "
106
+ ```
107
+
108
+ Use `RestoreStep` when: restoration is a straight token swap with no surrounding whitespace to absorb and no additional logic needed.
109
+
110
+ Use `TextStep` directly instead when: the placeholder was inserted with spaces around it (requiring `re.sub` with `\s*` to avoid double spaces), the marker should be deleted entirely rather than replaced, or post-replacement cleanup is needed.
111
+
112
+ ---
113
+
114
+ ## Writing tests
115
+
116
+ ### Unit tests for a step
117
+
118
+ Unit tests live under `tests/unit/steps/text/` or `tests/unit/steps/word/`, mirroring the step file structure.
119
+
120
+ The `tests/unit/steps/text/conftest.py` provides two fixtures and a helper:
121
+
122
+ - `operators` — a bare `LanguageOperators()` instance (language-agnostic)
123
+ - `english_operators` — an `EnglishOperators()` instance
124
+ - `assert_text_step_registered(step_cls)` — verifies the step is in the registry under its name
125
+
126
+ Every test file for a step should at minimum:
127
+
128
+ 1. Assert the step is registered.
129
+ 2. Instantiate the step with `MyStep()` and call it directly: `MyStep()(text, operators)`.
130
+ 3. Mutate `operators.config` fields in-place to cover different language configurations without creating a full language.
131
+
132
+ ```python
133
+ # tests/unit/steps/text/my_step_test.py
134
+ from normalization.languages.base import LanguageOperators
135
+ from normalization.steps.text.my_module import MyStep
136
+
137
+ from .conftest import assert_text_step_registered
138
+
139
+
140
+ def test_step_is_registered():
141
+ assert_text_step_registered(MyStep)
142
+
143
+
144
+ def test_my_step_basic(operators: LanguageOperators):
145
+ result = MyStep()("some input", operators)
146
+ assert result == "expected output"
147
+
148
+
149
+ def test_my_step_with_config(operators: LanguageOperators):
150
+ operators.config.some_field = "custom_value"
151
+ result = MyStep()("some input", operators)
152
+ assert result == "expected output with custom value"
153
+
154
+
155
+ def test_my_step_with_english(english_operators):
156
+ result = MyStep()("some input", english_operators)
157
+ assert result == "english-specific output"
158
+ ```
159
+
160
+ ### E2E tests for a preset
161
+
162
+ E2E tests validate the full pipeline (preset + language) against CSV fixtures. The test runner lives in `tests/e2e/normalization_test.py` and CSV files are organized under `tests/e2e/files/`.
163
+
164
+ **Directory structure** — one folder per preset, one CSV per language:
165
+
166
+ ```
167
+ tests/e2e/files/
168
+ gladia-3/
169
+ default.csv
170
+ de.csv
171
+ en.csv
172
+ fr.csv
173
+ it.csv
174
+ ```
175
+
176
+ **CSV format** — two columns (`input,expected`), no quoting needed unless the value contains a comma:
177
+
178
+ ```
179
+ input,expected
180
+ "$1,000,000",1000000 dollars
181
+ hello world,hello world
182
+ ```
183
+
184
+ The language is derived from the filename (e.g. `fr.csv` → language code `fr`). Use `default.csv` for the language-agnostic fallback.
185
+
186
+ **Adding test cases for an existing preset** — drop rows into the appropriate `{language_code}.csv` file, or create a new CSV if the language isn't covered yet. Tests are discovered automatically.
187
+
188
+ **Registering a new preset** — add a block to `normalization_test.py` following the existing pattern:
189
+
190
+ ```python
191
+ _MY_PRESET_DIR = _FILES_DIR / "my-preset"
192
+ _MY_PRESET_BY_LANGUAGE = _discover_preset_tests(_MY_PRESET_DIR)
193
+ _MY_PRESET_PIPELINES: dict[str, NormalizationPipeline] = {}
194
+
195
+ for _language in sorted(_MY_PRESET_BY_LANGUAGE):
196
+ globals()[f"test_my_preset_{_language}"] = _make_test(
197
+ "my-preset", _language, _MY_PRESET_BY_LANGUAGE[_language], _MY_PRESET_PIPELINES
198
+ )
199
+ ```
200
+
201
+ Pipelines are cached per language to avoid reloading for each parametrized case.
202
+
203
+ ---
204
+
205
+ ## Key design rules
206
+
207
+ - **Data vs. behavior**: if only the _values_ change by language, put them in `LanguageConfig`. If the _algorithm_ changes, override a method in `LanguageOperators`.
208
+ - **Steps are language-agnostic**: a step must not contain any language-specific logic or string literals. Read from `operators.config.*` or call `operators.method()`.
209
+ - **Presets are immutable**: never modify a published preset YAML — new behavior means a new preset file.
210
+ - **Placeholder pairs**: every `protect_*` step in Stage 1 must have a matching `restore_*` in Stage 3. The pipeline validates this at load time.
211
+ - **Language folders are self-contained**: everything specific to a language lives inside its folder. Helpers used only by one language (e.g. `number_normalizer.py`) go in that language's folder, not in `steps/`.
@@ -0,0 +1,3 @@
1
+ from normalization.cli import main
2
+
3
+ main()
@@ -0,0 +1,88 @@
1
+ import argparse
2
+ import json
3
+ import sys
4
+
5
+ from normalization import load_pipeline
6
+ from normalization.languages import get_language_registry
7
+ from normalization.pipeline.loader import _PRESETS_DIR
8
+
9
+
10
+ def _available_languages() -> list[str]:
11
+ import normalization.languages # noqa: F401 — triggers @register_language decorators
12
+
13
+ return sorted(get_language_registry().keys())
14
+
15
+
16
+ def _available_presets() -> list[str]:
17
+ return sorted(p.stem for p in _PRESETS_DIR.glob("*.yaml"))
18
+
19
+
20
+ def main() -> None:
21
+ parser = argparse.ArgumentParser(
22
+ prog="normalize",
23
+ description="Normalize STT transcription text for fair WER comparison.",
24
+ )
25
+ parser.add_argument(
26
+ "text",
27
+ nargs="?",
28
+ help="Text to normalize. Reads from stdin if omitted.",
29
+ )
30
+ parser.add_argument(
31
+ "--language",
32
+ "-l",
33
+ default="en",
34
+ metavar="CODE",
35
+ help="Language code (default: en). Available: %(choices)s.",
36
+ choices=_available_languages(),
37
+ )
38
+ parser.add_argument(
39
+ "--preset",
40
+ "-p",
41
+ default="gladia-3",
42
+ metavar="PRESET",
43
+ help="Built-in preset name or path to a YAML file (default: gladia-3).",
44
+ )
45
+ parser.add_argument(
46
+ "--file",
47
+ "-f",
48
+ metavar="PATH",
49
+ help="Path to a text file to normalize. Mutually exclusive with positional text.",
50
+ )
51
+ parser.add_argument(
52
+ "--describe",
53
+ action="store_true",
54
+ help="Print the pipeline description as JSON and exit.",
55
+ )
56
+
57
+ args = parser.parse_args()
58
+
59
+ if args.text is not None and args.file is not None:
60
+ parser.error("Provide either positional text or --file, not both.")
61
+
62
+ try:
63
+ pipeline = load_pipeline(args.preset, args.language)
64
+ except FileNotFoundError as exc:
65
+ parser.error(str(exc))
66
+
67
+ if args.describe:
68
+ print(json.dumps(pipeline.describe(), indent=2))
69
+ return
70
+
71
+ if args.file is not None:
72
+ try:
73
+ with open(args.file) as fh:
74
+ text = fh.read().strip()
75
+ except OSError as exc:
76
+ parser.error(str(exc))
77
+ elif args.text is not None:
78
+ text = args.text
79
+ elif not sys.stdin.isatty():
80
+ text = sys.stdin.read().strip()
81
+ else:
82
+ parser.error("Provide text as an argument, --file, or pipe it via stdin.")
83
+
84
+ print(pipeline.normalize(text))
85
+
86
+
87
+ if __name__ == "__main__":
88
+ main()
@@ -0,0 +1,15 @@
1
+ from . import dutch, english, french, german, italian, spanish
2
+ from .base import LanguageOperators
3
+ from .registry import get_language_registry, register_language
4
+
5
+ register_language(LanguageOperators)
6
+
7
+ __all__ = [
8
+ "dutch",
9
+ "english",
10
+ "french",
11
+ "german",
12
+ "italian",
13
+ "spanish",
14
+ "get_language_registry",
15
+ ]
@@ -0,0 +1,7 @@
1
+ from .operators import DutchOperators
2
+ from .replacements import DUTCH_REPLACEMENTS
3
+
4
+ __all__ = [
5
+ "DutchOperators",
6
+ "DUTCH_REPLACEMENTS",
7
+ ]