Skip to content

fix: handle full-width space in katakana-to-IPA conversion#1411

Merged
TinyKitten merged 2 commits into
devfrom
claude/fix-ipa-fullwidth-space-prwtk
Mar 5, 2026
Merged

fix: handle full-width space in katakana-to-IPA conversion#1411
TinyKitten merged 2 commits into
devfrom
claude/fix-ipa-fullwidth-space-prwtk

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Mar 5, 2026

Copy link
Copy Markdown
Member

Summary

  • 駅名に含まれる全角スペース(U+3000)が lookup_single で未定義だったため、katakana_to_ipaNone を返し nameIpa が null になっていた問題を修正
  • lookup_single に全角スペース   と半角スペース のマッピングを追加(IPA出力では半角スペースとして透過)
  • 「ドッキョウダイガクマエ ソウカマツバラ」のテストケースを追加

Test plan

  • SQLX_OFFLINE=true cargo test --lib domain::ipa — 42テスト全パス

https://claude.ai/code/session_01Pjo9E2fzdLZEkvNqxXAPeQ

Summary by CodeRabbit

  • バグ修正
    • IPA出力で全角スペースと半角スペースが正しく保持されるようになりました(テキスト内のスペースが意図した通り出力されます)。
  • テスト
    • 全角・半角スペースが単語間で維持されることを確認するテストを追加しました。

Station names like "ドッキョウダイガクマエ ソウカマツバラ" contain
a full-width space (U+3000) which was not mapped in lookup_single,
causing katakana_to_ipa to return None and nameIpa to be null.

https://claude.ai/code/session_01Pjo9E2fzdLZEkvNqxXAPeQ
@TinyKitten TinyKitten self-assigned this Mar 5, 2026
@coderabbitai

coderabbitai Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 75812f04-5cc7-4e5d-a895-9f51cf7714c1

📥 Commits

Reviewing files that changed from the base of the PR and between dcf25a0 and 5273ec0.

📒 Files selected for processing (1)
  • stationapi/src/domain/ipa.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • stationapi/src/domain/ipa.rs

📝 Walkthrough

Walkthrough

IPA変換のシングルキャラクタルックアップを拡張し、全角スペース(' ')と半角スペース(' ')を Phoneme::Regular(" ") として扱うように変更。スペースがIPA出力で保持されることを検証するテストを追加。

Changes

Cohort / File(s) Summary
IPAドメインモジュール
stationapi/src/domain/ipa.rs
シングルキャラクタルックアップに全角・半角スペースのマッピング(' ' および ' ' → Phoneme::Regular(" "))を追加。スペース保持を確認するテストケースを追加。

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 ことばの間に ふわりと一つ
全角も半角も 同じぬくもり
IPAの道を そっと渡る
ウサギが祝う スペースの舞 🎋

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、カタカナ-IPA変換における全角スペース処理の修正という主要な変更を明確かつ簡潔に要約しており、チェンジセットの主なポイントを正確に反映しています。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/fix-ipa-fullwidth-space-prwtk

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
stationapi/src/domain/ipa.rs (1)

594-601: 半角スペースの回帰テストも追加しておくとより堅牢です。

実装は全角・半角の両方を受け付けるため、半角スペース入力のケースも 1 件入れておくと将来の退行を防ぎやすいです。

✅ 追加テスト例
     #[test]
     fn test_dokkyo_daigakumae_soka_matsubara() {
         // Full-width space between words should be preserved
         assert_eq!(
             ipa("ドッキョウダイガクマエ ソウカマツバラ"),
             "dokkʲoːdaiɡakɯmae soːkamat͡sɯbaɾa"
         );
     }
+
+    #[test]
+    fn test_dokkyo_daigakumae_soka_matsubara_half_width_space() {
+        assert_eq!(
+            ipa("ドッキョウダイガクマエ ソウカマツバラ"),
+            "dokkʲoːdaiɡakɯmae soːkamat͡sɯbaɾa"
+        );
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@stationapi/src/domain/ipa.rs` around lines 594 - 601, Add a sibling unit test
that mirrors test_dokkyo_daigakumae_soka_matsubara but uses a half-width (ASCII)
space between the two phrases to ensure ipa(...) accepts both full-width and
half-width spaces; create a test function (e.g.,
test_dokkyo_daigakumae_soka_matsubara_halfwidth) that calls ipa("ドッキョウダイガクマエ
ソウカマツバラ") and asserts the same expected transcription "dokkʲoːdaiɡakɯmae
soːkamat͡sɯbaɾa", referencing the existing ipa function and test pattern so the
regression is covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@stationapi/src/domain/ipa.rs`:
- Around line 594-601: Add a sibling unit test that mirrors
test_dokkyo_daigakumae_soka_matsubara but uses a half-width (ASCII) space
between the two phrases to ensure ipa(...) accepts both full-width and
half-width spaces; create a test function (e.g.,
test_dokkyo_daigakumae_soka_matsubara_halfwidth) that calls ipa("ドッキョウダイガクマエ
ソウカマツバラ") and asserts the same expected transcription "dokkʲoːdaiɡakɯmae
soːkamat͡sɯbaɾa", referencing the existing ipa function and test pattern so the
regression is covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d65f304d-f54a-4d78-9aa9-7a060e34e016

📥 Commits

Reviewing files that changed from the base of the PR and between 63b86ca and dcf25a0.

📒 Files selected for processing (1)
  • stationapi/src/domain/ipa.rs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants