Repository navigation
feat: 半角の数量を位取りで読む - #34
Merged
Merged
Conversation
半角数字の数量が一桁ずつの読みになっていたため、元入力で数量と識別子を判定し、明確な数量の数詞範囲を最良パスの後でまとめる。 カンマ区切りと小数、百・千・万・億・兆を扱い、数詞と助数詞の補正につなげる。 登録済みの辞書語を優先し、番号・不正な表記・空白で離れた単位を保護する。合成した数詞は原入力の表層・位置を保持し、コストを合計する。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
半角数字の数量が1桁ずつ読まれ、「10分」がイチゼロフン、「1,000円」がイチ・カンマ・ゼロゼロゼロエンになっていました。元入力で数量と識別子を判定し、最良パスの後で数詞の範囲を1トークンにまとめ、位取りの読みと助数詞の補正を適用します。
助数詞・年度・位の数詞・許可した英字単位に隣接する数量を対象にします。整数部と小数部はそれぞれ16桁まで、整数は兆まで扱います。桁区切りと小数の構文を検査し、単独の数、番号、不正形式、符号付き数、混在・全角数字、空白で離れた単位を保護します。登録済みの「2026年度」「2.5倍」などは優先します。
数詞の合成では原入力の表層・原形・UTF-8範囲を保持し、コストを広い型で合計して最後にi16へ飽和させます。既存出力を変更せず、元入力の候補と保護状態をチャンク・文をまたいで線形に処理します。
設計・差分レビューの指摘を採用し、候補全体の構文検査、英字単位の完全一致、保護された「兆」と混在表記の補正防止、チャンクをまたぐ保護cursorを実装しました。既存の1桁数字の音便を一律に止める提案は、#30の既存出力を変えるため採用せず、新しい位取り・音便の補正を保護しています。最終レビューでは指摘なしでした。
検証:
Closes #31