feat(input): カタカナから英単語候補を追加 - #375
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 Changes recommended
「カタカナ入力のみ」という説明と実装の挙動(ひらがなでも発火しうる)が一致しておらず、仕様の明確化/コード側のガード追加が必要です。
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
カタカナで入力した外来語に対して、対応する英単語(小文字/先頭大文字)を通常の変換候補へ混ぜ込む機能を追加するPRです。通信や機械的ローマ字化は行わず、アプリ同梱の対応表にある語だけを候補化する方針になっています。
Changes:
- カタカナ外来語→英単語(lowercase / sentence case)対応表
KatakanaEnglishCandidatesを追加 - 変換候補生成時に、対応表に一致した場合は英単語候補を
mainResultsに挿入 - 上記の動作を検証するテストを追加
File summaries
| File | Description |
|---|---|
| Core/Tests/CoreTests/InputUtilsTests/KatakanaEnglishCandidatesTests.swift | 対応表の返却値と、変換候補への混入をテストで検証 |
| Core/Sources/Core/InputUtils/SegmentsManager.swift | 候補生成結果に英単語候補を追加挿入する処理を追加 |
| Core/Sources/Core/InputUtils/KatakanaEnglishCandidates.swift | 外来語(カタカナ読み)→英単語の明示的な対応表と variants 生成を実装 |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if self.composingText.isAtEndIndex { | ||
| let reading = self.composingText.convertTarget.toKatakana() | ||
| let englishWords = KatakanaEnglishCandidates.variants(for: reading) | ||
| if !englishWords.isEmpty { | ||
| var seen = Set(result.mainResults.map(\.text)) | ||
| let candidates = englishWords.compactMap { word -> Candidate? in | ||
| guard seen.insert(word).inserted else { | ||
| return nil | ||
| } | ||
| return Candidate( | ||
| text: word, | ||
| value: -18, | ||
| composingCount: .surfaceCount(self.composingText.convertTarget.count), | ||
| lastMid: MIDData.一般.mid, | ||
| data: [.init(word: word, ruby: reading, cid: CIDData.固有名詞.cid, mid: MIDData.一般.mid, value: -18)], | ||
| isLearningTarget: false | ||
| ) | ||
| } | ||
| result.mainResults.insert(contentsOf: candidates, at: min(5, result.mainResults.count)) | ||
| } | ||
| } |
|
申し訳ありません。個人用として利用する予定の実装を、誤ってコントリビュート用のPRとして提出してしまいました。本機能は自分のフォーク内で管理することにしたため、このPRは取り下げます。お手数をおかけしてしまい、失礼いたしました。 |
概要
カタカナで入力した外来語に対応する英単語を、通常の変換候補として追加します。
例:
セキュリティ→security/Securityディスプレイ→display/Displayスマートフォン→smartphone/Smartphoneベッド→bed/Bedマウス→mouse/Mouseキーボード→keyboard/Keyboard通信や機械的なローマ字化は行わず、カタカナ読みと英語表記の対応表をアプリに同梱します。日常語、デジタル作業、仕事で使う語を収録し、未知の語は推測候補にしません。
確認
swift testswiftlint --quiet --strictxcodebuild -project azooKeyMac.xcodeproj -scheme azooKeyMac -configuration Debug -sdk macosx CODE_SIGNING_ALLOWED=NO build