Repository navigation
Conversation
- ZipCodeDictionary を追加し、利用側でダウンロードした utf_ken_all.csv / .zip を読み込めるようにした - 郵便番号の町域名で住所を住所A・住所Bに分割する TrySplitAddress を追加 (都道府県名の省略、「大字」「字」、空白、全角・半角、ヶ/ケ の違いを吸収) - BarCode.Create(郵便番号, 住所, 郵便番号データ) を追加し、住所Bだけから抜き出すようにした - 郵便番号データを使う場合は、代表の郵便番号を郵便番号データに基づいて判定する - README と CLAUDE.md を更新 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HNb8H3ydQTR8dWU8d28osE
- 代表の郵便番号(以下に掲載がない場合)では住所を分割しないようにした - 郵便番号データにない郵便番号は、代表の郵便番号を下2けたで判定するようにした - 住所A・B版の Create で住所Aを取り除くとき、郵便番号データと同じ照合 (空白、全角・半角、ヶ/ケ を区別しない)を使うようにした - 郵便番号の正規化と郵便番号データの検索を1回にまとめた - 都道府県名・市区町村名の文字列を共有し、メモリ使用量を約30MBから約22MBに削減 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HNb8H3ydQTR8dWU8d28osE
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レコード1行、UTF-8形式)を利用者側で指定して読み込めるようにしました。データはリポジトリに同梱していません。
郵便番号の町域名で住所を住所A(町域名まで)と住所B(町域名以降)に自動で分割できるようになり、住所全体を渡しても町域名の漢数字を抜き出さなくなります。
追加した API(コア、外部依存なし)
ZipCodeDictionary.Load(パス)/Load(Stream)utf_ken_all.csv、または zip(utf_ken_all.zip)のまま読み込む。Load(Stream)は渡された Stream を閉じないdictionary.IsRepresentative(郵便番号)true。データにない番号(事業所の個別番号など)はnulldictionary.Find(郵便番号)/Contains(郵便番号)dictionary.TrySplitAddress(郵便番号, 住所, out 住所A, out 住所B)BarCode.Create(郵便番号, 住所, 郵便番号データ)町域名の特殊な値
代表の郵便番号の判定(
IsRepresentativeZipCode)郵便番号データに基づいて判定します。データにない番号(郵便番号データより新しい番号など)は、データなしのときと同じく下2けたで判定します。
住所A・B 版の
Createの変更住所Aを取り除くときの照合を、郵便番号データと同じ方法(空白、全角・半角、「ヶ/ケ」を区別しない)にそろえました。
読み込み時のエラー
列数が違う・郵便番号が 7 桁の数値でない・UTF-8 として読めない文字がある、のいずれかで行番号付きのエラーにします。最後のチェックで、従来の Shift_JIS 形式(KEN_ALL.CSV)の取り違えを検出します。
実データでの確認
2026年10月30日更新の
utf_ken_all.csvで確認しました(データはリポジトリに含めていません)。1-5-3・8-2-1-1・3-1-2が5-3・2-1-1・1-2になった全町域の分割は、データ自身から組み立てた住所での検証です。実際の住所の書き方の揺れまでは確かめていません。
コードレビューへの対応
Createの照合を郵便番号データと同じにした。BarCode.Create(郵便番号, "…", null)が曖昧になる点は、2.0.0 が未公開で影響を受ける利用者がいないため見送った。テスト
dotnet testで 176 件すべて成功(42 件追加)。TestData/ken_all_sample.csvは、utf_ken_all.csv の形式で手書きしたもの(実データの抜粋ではない)。🤖 Generated with Claude Code
https://claude.ai/code/session_01HNb8H3ydQTR8dWU8d28osE