feat: add lightweight user word registration (単語登録) tab#25
Open
presire wants to merge 1 commit into
Open
Conversation
Introduce a simple user-word registration feature that lets users register
(reading → word) pairs and have them surfaced at the top of the conversion
candidate list. The feature is implemented as a thin post-processing layer
in hazkey-server and a new tab in hazkey-settings, intentionally kept
independent from AzooKeyKanaKanjiConverter so that no upstream converter
changes are required.
This is complementary to — not a replacement for — the existing placeholder
"辞書" tab, which is reserved for a future full user dictionary that would
be integrated into the converter with part-of-speech, cost, and connection
information. The new "単語登録" tab covers the common "I just want my email
address to come up when I type an alias" use case today, without blocking
the proper dictionary work.
Storage
-------
Entries are stored in ~/.config/hazkey/user_dictionary.tsv as plain TSV:
reading<TAB>word<TAB>comment
Lines starting with '#' and empty lines are ignored. Readings are
normalized to NFC for matching.
hazkey-server
-------------
* New userDictionary.swift: loads the TSV on startup and reloads it
automatically when the file's mtime changes. No server restart or IPC
round-trip is required after editing the file.
* state.swift: introduces a DisplayedCandidate enum so each displayed
candidate is tagged as either .fromConverter(Candidate) or
.fromUserDict(word:). During getCandidates(), entries whose reading
exactly matches the current hiragana input are prepended to the
candidate list. On commit, user-dictionary entries clear the composing
text directly and bypass the converter's learning store.
hazkey-settings
---------------
* New UserDictTab (userdicttab.h / userdicttab.cpp): QTableWidget-based UI
with Add / Edit / Delete buttons and a modal entry dialog. The tab reads
and writes the TSV file directly — no new IPC messages are introduced.
* mainwindow.cpp: inserts the tab between "入力スタイル" and "辞書" using
ui_->dictionaryTab as an anchor, so it stays correctly placed even if
tab order changes later.
* CMakeLists.txt: registers the new sources.
* hazkey-settings_ja_JP.ts: Japanese translations for all new strings
(tab label "単語登録", column headers, buttons, dialogs, error messages).
Protocol
--------
No changes to protocol/*.proto. The generated .pb.swift files are not
regenerated, so builds do not require protoc-gen-swift.
Known limitations (by design)
-----------------------------
* Exact full-reading match only; prefix matches are not surfaced.
* No part-of-speech information, so entries do not participate in
mid-sentence conversion.
* Not integrated with the learning store; selecting a registered word
does not influence conversion frequency.
These trade-offs keep the feature self-contained and allow it to ship
without touching AzooKeyKanaKanjiConverter.
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.
単語登録機能 ([単語登録]タブ) の追加
本PRは
hazkey-settingsとhazkey-serverに単語登録機能を追加します。AzooKeyKanaKanjiConverterには一切手を入れず、hazkey-server側の後処理レイヤとして実装しているため、上流コンバータへの変更は不要です。
既存の[辞書]タブ (プレースホルダ) が将来実装する本格的なユーザ辞書機能とは競合せず、棲み分け可能な設計にしています。
既存の[辞書]タブとの関係
[辞書]タブは、AzooKeyKanaKanjiConverter本体に組み込まれる本格的なユーザ辞書機能 (品詞情報・コスト・連接情報を持ち、文法解析や学習に参加する) のプレースホルダであり、
実現には上流コンバータへの変更が必要です。
一方、本PRで追加する[単語登録]タブは異なる、ミニマルなアプローチを取っています。
両者は排他的ではありません。
将来、[辞書]タブに本格的なユーザ辞書機能が実装された後も、[単語登録]タブは単純な文字列置換用途の軽量な代替手段として残すことも、
役割を終えて削除することも可能です。
本PRで実装した内容
~/.config/hazkey/user_dictionary.tsvによみ<TAB>単語<TAB>コメント形式でエントリを保存起動時にTSVを読み込み、ファイルのmtimeを監視して自動リロード (サーバ再起動不要)
候補生成時、入力よみと完全一致するエントリを候補リストの先頭に差し込みます。
ユーザ辞書由来の候補を確定した場合は学習ストアをバイパスします。
[入力スタイル]タブと[辞書]タブの間に[単語登録]タブを追加。
テーブルビューと追加・編集・削除ボタン、エントリ編集ダイアログを備えます。
このタブはTSVファイルを直接読み書きするため、新しいIPCメッセージは一切導入していません。
protocol/*.protoは一切変更していないため、.pb.swiftの再生成も不要です。既知の制限事項 (意図的なトレードオフ)
登録したよみの前方一致では候補に出ません。
文中変換には参加しません。
登録語を選択しても変換頻度学習には影響しません。
これらはいずれも、機能を自己完結させAzooKeyKanaKanjiConverterに手を加えないための意図的な設計判断です。
本格的な辞書機能は、将来[辞書]タブで上流コンバータと統合する形で実装されることを想定しています。