You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add api/accent/reading_overrides.py — a context-blind correction layer
sitting between Yahoo Furigana and OJAD alignment. Each override is a
regex on the concatenated surface text plus the replacement tokens that
should appear instead. Covers:
- 曜日 brackets: (月)/(月)→ げつ, (土) → ど, etc. for all 7 weekdays.
- All 31 day-of-month readings: 1日 → ついたち (atamadaka), 5日 → いつか,
14日 → じゅうよっか, 20日 → はつか, etc.
- N日間 durations 1-31: 1日間 → いちにちかん (NOT ついたちかん since
the 1st-of-month reading is impossible for a duration), 7日間 →
しちにちかん (modern technical writing preference over なのかかん).
- 20歳 / 二十歳 / 20才 → はたち (the only irregular age reading).
Patterns accept arabic / full-width / kanji numeral variants of the
same N so `3月5日(土)` / `3月5日(土)` / `三月五日(土)` all trigger
the same overrides. Order-of-overrides matters: duration list precedes
date list so `N日間` wins over `N日` at the same start (longer match
breaks ties in _collect_matches).
apply_furigana_overrides runs BEFORE align_accent so merged spans like
`5日→いつか` reach OJAD as a single token whose furigana matches OJAD's
phrase reading (the numeric-anchor logic in align_accent otherwise
cascades-fails because numeric tokens lack any Yahoo furigana).
apply_accent_overrides runs AFTER align to re-stamp both furigana and
accent on the same matched spans, so the response is consistent.
Adds URL preprocessing: each https?:// is swapped for the placeholder
"URLPLACEHOLDER" before the pipeline runs (Yahoo fragments URLs across
several alphabet tokens; OJAD's phrasing scraper produces noise for
Latin punctuation runs — both drag alignment off-rail). Placeholders
are walked back to the originals in order after alignment. URL body
stops at whitespace, any Japanese char, or `,()<>[]"'` so embedded
URLs strip cleanly.
Adds a non-Japanese short-circuit: if (after URL stripping) the chunk
contains no hiragana / katakana / CJK ideograph, skip Yahoo + OJAD
entirely and echo the chunk back as a single token. Lets pure-URL /
pure-English lines stream through cheaply.
Also adds stream_accent_chunks() to pipeline.py as a helper used by
the streaming endpoint added in the next commit. Splits the input on
\n then on full-width sentence terminators (。!?.) — long
paragraphs degrade OJAD's phrasing predictor and parallelising across
sentences caps the latency. In-flight work is bounded by a semaphore
(concurrency=4) because OJAD's u-tokyo backend falls over with 30+
parallel scrapes.
main.py docstring updated to reflect /MarkAccent/stream/.
Refs #47.
0 commit comments