feat: Add normalization settings for currency conversion and footnote removal in UI

This commit is contained in:
JB
2025-12-01 20:00:56 -08:00
parent baef01ad45
commit aa53438acf
4 changed files with 52 additions and 31 deletions
+1
View File
@@ -175,6 +175,7 @@ def build_apostrophe_config(
config = replace(base or ApostropheConfig()) config = replace(base or ApostropheConfig())
config.convert_numbers = bool(settings.get("normalization_numbers", True)) config.convert_numbers = bool(settings.get("normalization_numbers", True))
config.convert_currency = bool(settings.get("normalization_currency", True)) config.convert_currency = bool(settings.get("normalization_currency", True))
config.remove_footnotes = bool(settings.get("normalization_footnotes", True))
config.year_pronunciation_mode = str(settings.get("normalization_numbers_year_style", "american") or "").strip().lower() config.year_pronunciation_mode = str(settings.get("normalization_numbers_year_style", "american") or "").strip().lower()
config.add_phoneme_hints = bool(settings.get("normalization_phoneme_hints", True)) config.add_phoneme_hints = bool(settings.get("normalization_phoneme_hints", True))
config.contraction_mode = "expand" if settings.get("normalization_apostrophes_contractions", True) else "keep" config.contraction_mode = "expand" if settings.get("normalization_apostrophes_contractions", True) else "keep"
+2
View File
@@ -58,6 +58,8 @@ _NORMALIZATION_BOOLEAN_KEYS = {
"normalization_contraction_modal_would", "normalization_contraction_modal_would",
"normalization_contraction_negation_not", "normalization_contraction_negation_not",
"normalization_contraction_let_us", "normalization_contraction_let_us",
"normalization_currency",
"normalization_footnotes",
} }
_NORMALIZATION_STRING_KEYS = { _NORMALIZATION_STRING_KEYS = {
+3
View File
@@ -531,8 +531,11 @@ function collectNormalizationSettings() {
} }
const normalization = { const normalization = {
normalization_numbers: Boolean(form.querySelector('input[name="normalization_numbers"]')?.checked), normalization_numbers: Boolean(form.querySelector('input[name="normalization_numbers"]')?.checked),
normalization_currency: Boolean(form.querySelector('input[name="normalization_currency"]')?.checked),
normalization_titles: Boolean(form.querySelector('input[name="normalization_titles"]')?.checked), normalization_titles: Boolean(form.querySelector('input[name="normalization_titles"]')?.checked),
normalization_footnotes: Boolean(form.querySelector('input[name="normalization_footnotes"]')?.checked),
normalization_terminal: Boolean(form.querySelector('input[name="normalization_terminal"]')?.checked), normalization_terminal: Boolean(form.querySelector('input[name="normalization_terminal"]')?.checked),
normalization_caps_quotes: Boolean(form.querySelector('input[name="normalization_caps_quotes"]')?.checked),
normalization_phoneme_hints: Boolean(form.querySelector('input[name="normalization_phoneme_hints"]')?.checked), normalization_phoneme_hints: Boolean(form.querySelector('input[name="normalization_phoneme_hints"]')?.checked),
normalization_apostrophes_contractions: Boolean(form.querySelector('input[name="normalization_apostrophes_contractions"]')?.checked), normalization_apostrophes_contractions: Boolean(form.querySelector('input[name="normalization_apostrophes_contractions"]')?.checked),
normalization_apostrophes_plural_possessives: Boolean(form.querySelector('input[name="normalization_apostrophes_plural_possessives"]')?.checked), normalization_apostrophes_plural_possessives: Boolean(form.querySelector('input[name="normalization_apostrophes_plural_possessives"]')?.checked),
+46 -31
View File
@@ -284,56 +284,39 @@
<section class="settings-panel" data-section="normalization"> <section class="settings-panel" data-section="normalization">
<fieldset class="settings__section"> <fieldset class="settings__section">
<legend>Normalization Rules</legend> <legend>General Rules</legend>
<div class="field field--choices"> <div class="field field--choices">
<label class="toggle-pill"> <label class="toggle-pill">
<input type="checkbox" name="normalization_numbers" value="true" {% if settings.normalization_numbers %}checked{% endif %}> <input type="checkbox" name="normalization_numbers" value="true" {% if settings.normalization_numbers %}checked{% endif %}>
<span>Convert grouped numbers to words</span> <span>Convert grouped numbers to words</span>
</label> </label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_currency" value="true" {% if settings.normalization_currency %}checked{% endif %}>
<span>Convert currency symbols ($10 &rarr; ten dollars)</span>
</label>
<label class="toggle-pill"> <label class="toggle-pill">
<input type="checkbox" name="normalization_titles" value="true" {% if settings.normalization_titles %}checked{% endif %}> <input type="checkbox" name="normalization_titles" value="true" {% if settings.normalization_titles %}checked{% endif %}>
<span>Expand titles and suffixes (Dr., St., Jr., …)</span> <span>Expand titles and suffixes (Dr., St., Jr., …)</span>
</label> </label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_footnotes" value="true" {% if settings.normalization_footnotes %}checked{% endif %}>
<span>Remove footnote indicators ([1], [2])</span>
</label>
<label class="toggle-pill"> <label class="toggle-pill">
<input type="checkbox" name="normalization_terminal" value="true" {% if settings.normalization_terminal %}checked{% endif %}> <input type="checkbox" name="normalization_terminal" value="true" {% if settings.normalization_terminal %}checked{% endif %}>
<span>Ensure sentences end with terminal punctuation</span> <span>Ensure sentences end with terminal punctuation</span>
</label> </label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_phoneme_hints" value="true" {% if settings.normalization_phoneme_hints %}checked{% endif %}>
<span>Add phoneme hints for possessives</span>
</label>
<label class="toggle-pill"> <label class="toggle-pill">
<input type="checkbox" name="normalization_caps_quotes" value="true" {% if settings.normalization_caps_quotes %}checked{% endif %}> <input type="checkbox" name="normalization_caps_quotes" value="true" {% if settings.normalization_caps_quotes %}checked{% endif %}>
<span>Convert ALL CAPS dialogue inside quotes</span> <span>Convert ALL CAPS dialogue inside quotes</span>
</label> </label>
<span class="field__caption">Apostrophes</span>
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_contractions" value="true" {% if settings.normalization_apostrophes_contractions %}checked{% endif %}>
<span>Expand contractions ("it's" -> "it is")</span>
</label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_plural_possessives" value="true" {% if settings.normalization_apostrophes_plural_possessives %}checked{% endif %}>
<span>Collapse plural possessives (dogs' -> dogs)</span>
</label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_sibilant_possessives" value="true" {% if settings.normalization_apostrophes_sibilant_possessives %}checked{% endif %}>
<span>Add guidance for sibilant possessives (boss's -> boss + IZ marker)</span>
</label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_decades" value="true" {% if settings.normalization_apostrophes_decades %}checked{% endif %}>
<span>Expand decades ('90s -> 1990s)</span>
</label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_leading_elisions" value="true" {% if settings.normalization_apostrophes_leading_elisions %}checked{% endif %}>
<span>Expand leading elisions ('tis -> it is)</span>
</label>
</div>
<div class="field field--inline field--actions">
<button type="button" class="button button--ghost button--small" data-action="contraction-modal-open">Advanced…</button>
<p class="hint">Choose which contraction families are expanded.</p>
</div> </div>
</fieldset>
<fieldset class="settings__section">
<legend>Apostrophes &amp; Contractions</legend>
<div class="field"> <div class="field">
<span class="field__label">Apostrophe strategy</span> <span class="field__label">Strategy</span>
<div class="choices choices--inline"> <div class="choices choices--inline">
{% for option in apostrophe_modes %} {% for option in apostrophe_modes %}
<label class="radio-pill"> <label class="radio-pill">
@@ -346,7 +329,39 @@
<p class="hint hint--warning">Configure the LLM connection before using it for audiobook runs.</p> <p class="hint hint--warning">Configure the LLM connection before using it for audiobook runs.</p>
{% endif %} {% endif %}
</div> </div>
<div class="field field--choices">
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_contractions" value="true" {% if settings.normalization_apostrophes_contractions %}checked{% endif %}>
<span>Expand contractions ("it's" &rarr; "it is")</span>
</label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_plural_possessives" value="true" {% if settings.normalization_apostrophes_plural_possessives %}checked{% endif %}>
<span>Collapse plural possessives (dogs' &rarr; dogs)</span>
</label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_sibilant_possessives" value="true" {% if settings.normalization_apostrophes_sibilant_possessives %}checked{% endif %}>
<span>Add guidance for sibilant possessives (boss's &rarr; boss + IZ marker)</span>
</label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_decades" value="true" {% if settings.normalization_apostrophes_decades %}checked{% endif %}>
<span>Expand decades ('90s &rarr; 1990s)</span>
</label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_apostrophes_leading_elisions" value="true" {% if settings.normalization_apostrophes_leading_elisions %}checked{% endif %}>
<span>Expand leading elisions ('tis &rarr; it is)</span>
</label>
<label class="toggle-pill">
<input type="checkbox" name="normalization_phoneme_hints" value="true" {% if settings.normalization_phoneme_hints %}checked{% endif %}>
<span>Add phoneme hints for possessives</span>
</label>
</div>
<div class="field field--inline field--actions">
<button type="button" class="button button--ghost button--small" data-action="contraction-modal-open">Advanced Contraction Settings…</button>
<p class="hint">Choose which contraction families are expanded.</p>
</div>
</fieldset> </fieldset>
<fieldset class="settings__section"> <fieldset class="settings__section">
<legend>Sample &amp; Preview</legend> <legend>Sample &amp; Preview</legend>
<div class="field field--inline"> <div class="field field--inline">