mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
feat: Update year normalization logic to reflect US-style pronunciation for years 1100-1999; adjust related tests for consistency
This commit is contained in:
@@ -1586,8 +1586,8 @@ def _normalize_grouped_numbers(text: str, cfg: ApostropheConfig) -> str:
|
||||
return words.replace(" and ", " ")
|
||||
return None
|
||||
|
||||
# 1200s are commonly spoken as "twelve hundred".
|
||||
if 1200 <= value < 1300:
|
||||
# US-style: 1100-1999 are often spoken as "X hundred Y".
|
||||
if 1100 <= value <= 1999:
|
||||
hundreds = value // 100
|
||||
remainder = value % 100
|
||||
prefix = _words(hundreds)
|
||||
|
||||
@@ -92,7 +92,8 @@ def update_settings() -> ResponseReturnValue:
|
||||
for key in _NORMALIZATION_BOOLEAN_KEYS:
|
||||
current[key] = _extract_checkbox(key, bool(current.get(key, True)))
|
||||
for key in _NORMALIZATION_STRING_KEYS:
|
||||
current[key] = (form.get(key) or "").strip()
|
||||
if hasattr(form, "__contains__") and key in form:
|
||||
current[key] = (form.get(key) or "").strip()
|
||||
|
||||
# Integrations
|
||||
current["integrations"] = current.get("integrations", {})
|
||||
|
||||
@@ -316,6 +316,12 @@ def normalize_setting_value(key: str, value: Any, defaults: Dict[str, Any]) -> A
|
||||
if normalized_mode in {"off", "spacy", "llm"}:
|
||||
return normalized_mode
|
||||
return defaults[key]
|
||||
if key == "normalization_numbers_year_style":
|
||||
if isinstance(value, str):
|
||||
normalized_style = value.strip().lower()
|
||||
if normalized_style in {"american", "off"}:
|
||||
return normalized_style
|
||||
return defaults[key]
|
||||
if key == "llm_context_mode":
|
||||
if isinstance(value, str):
|
||||
normalized_scope = value.strip().lower()
|
||||
|
||||
Reference in New Issue
Block a user