Skip to content

Commit 8bc3781

Browse files
committed
fix(accent): preserve suffix lexical metadata
1 parent c549047 commit 8bc3781

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

api/accent/reading_overrides.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,9 @@ def _patch_first_mora_fall(token: WordAccentResult) -> WordAccentResult:
743743
pos1=token.pos1,
744744
conjugation_type=token.conjugation_type,
745745
conjugation_form=token.conjugation_form,
746+
lexical_kernel=token.lexical_kernel,
747+
lexical_kernel_alts=token.lexical_kernel_alts,
748+
kernel_absorbed=token.kernel_absorbed,
746749
)
747750

748751

tests/test_reading_regressions.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
import pytest
66

77
from api.accent import reading_overrides
8-
from api.accent.models import WordAccentResult, WordResult
8+
from api.accent.models import AccentInfo, WordAccentResult, WordResult
99
from api.accent.reading_overrides import (
1010
FuriganaOverride,
1111
ReplacementToken,
1212
apply_accent_overrides,
13+
apply_accent_patches,
1314
apply_furigana_overrides,
1415
)
1516

@@ -164,3 +165,30 @@ def test_weekday_override_accepts_fullwidth_parentheses() -> None:
164165
("土", "ど"),
165166
(")", ")"),
166167
]
168+
169+
170+
def test_suffix_accent_patch_preserves_strong_mode_metadata() -> None:
171+
# Given
172+
token = WordAccentResult(
173+
surface="ます",
174+
furigana="ます",
175+
accent=[
176+
AccentInfo(furigana="ま", accent_marking_type=1, length=1),
177+
AccentInfo(furigana="す", accent_marking_type=1, length=1),
178+
],
179+
base="ます",
180+
pos="助動詞",
181+
conjugation_type="助動詞-マス",
182+
conjugation_form="終止形-一般",
183+
lexical_kernel=1,
184+
lexical_kernel_alts=[1, 0],
185+
kernel_absorbed=True,
186+
)
187+
188+
# When
189+
result = apply_accent_patches([token])[0]
190+
191+
# Then
192+
assert result.lexical_kernel == 1
193+
assert result.lexical_kernel_alts == [1, 0]
194+
assert result.kernel_absorbed is True

0 commit comments

Comments
 (0)