バス停の翻訳をfield_valueキー・半角カナに対応し英語表記と読みを補完#1606
Merged
Merged
Conversation
前回のローマ字化フォールバックだけでは京王バス・東急コミュニティバスの 英語表記も読みも入らなかった。原因は GTFS-JP translations.txt のキー方式 とカラム構成がフィード毎に異なることだった: - 西武: record_id キー・6列(record_sub_idなし)・全角カナ → 従来動作 - 京王/東急(大田/品川/目黒): field_value(日本語駅名)キーで record_id 空・ 7列・ja-Hrkt が半角カナ → 従来ローダーが record.get(4) 決め打ち& record_id のみ参照だったため全取りこぼし。結果 station_name_k に漢字が 入り station_name_r は空になっていた。 対応: - load_gtfs_translations をヘッダー名でカラム解決するよう変更し、record_id と field_value の両方をキーとして索引。import_gtfs_stops は stop_id → 停留所名(field_value) の順で翻訳を引く。 - 半角カナ読み(ニシハチオウジ 等、結合濁点含む)を to_fullwidth_katakana() で 全角カナに正規化してから格納。 - en があればそれを station_name_r に採用(本物の英語を優先)。en が無い フィード(東急一般路線JSON等)は従来どおりカナからローマ字生成。 実データ(ODPT)で全事業者の translations.txt 構成を確認済み。ローダーの 両キー方式・列数差・半角カナのユニットテストを追加。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJ8JoyxRvZsX6XfEKuQEwZ
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughGTFS-JPの ChangesGTFS翻訳と停留所名生成
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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.
概要
京王バス・東急コミュニティバス(大田/品川/目黒)で、停留所の英語表記(
station_name_r)も読み(station_name_k)も入らず、station_name_kに漢字が入る問題を修正します。原因は GTFS-JPtranslations.txtのキー方式とカラム構成がフィード毎に異なるのに、ローダーが片方(record_id・固定列位置)しか見ていなかったことでした。変更の種類
変更内容
実データ(ODPT)で全事業者の
translations.txt構成を確認し、以下が判明:record_idfield_value(日本語駅名, record_id空)従来の
load_gtfs_translationsはrecord.get(4)決め打ち&record_idのみを索引していたため、field_valueキーのフィードを丸ごと落としていました。結果station_name_kに漢字が入りstation_name_rは空になっていました。load_gtfs_translations: カラムをヘッダー名で解決するよう変更(6列/7列の差を吸収)。stop_name翻訳をrecord_id(停留所ID、-NNポール接尾辞は親IDにもマップ)とfield_value(日本語駅名)の両方でキー索引。import_gtfs_stops: 翻訳を stop_id → 停留所名(field_value) の順で参照。enがあれば本物の英語をstop_name_rに採用し、無いフィード(東急一般路線)は従来どおりカナからヘボン式ローマ字を生成。romaji::to_fullwidth_katakana: 半角カナ読み(ニシハチオウジ等、結合濁点/半濁点対応)を全角カナへ正規化してから格納。AGENTS.mdに翻訳キー方式とフォールバックの仕様を追記。station_name_rは駅名 projection・名称検索・ローマ字系統/行先名すべての上流ソースのため、この修正で英語表示面が一括で埋まります。テスト
cargo fmt --all -- --checkが通ることcargo clippy -- -D warningsが通ることcargo test(SQLX_OFFLINE=true)が通ることSQLX_OFFLINE=true cargo test --lib --bin stationapi→ lib 425 + bin 38 passed(ローダーの両キー方式・列数差・半角カナ正規化のユニットテストを追加)cargo fmt -p stationapi -- --check→ 差分なし /cargo clippy --all-targets --all-features→ 警告なし実データ(ODPT全事業者)で PostgreSQL にインポートし検証:
name_katakana=ニシハチオウジエキミナミグチ(漢字→正しい全角カナ)、name_r=Nishi-hachioji Sta. South(本物の英語)Ēdanmōrufukasawa,Tamagawaeki等)が動作関連Issue
スクリーンショット(任意)
Generated by Claude Code
Summary by CodeRabbit
バグ修正
ドキュメント