* fix(engine): recognize complete umlaut aliases in quanpin * refactor(engine): 移除九键输入 九键会话只有引擎公共 Session 门面在用,Server 与 TSF 都没有接入。删掉 NineKeySession、Session 的九键入口与 SessionSnapshot::nine_key_spellings, 以及对应测试和注释。 * fix(engine,server): ü 别名共用一条归一规则,入库与纠错不再产出查不到的键 - 新增 quanpin::is_jqxy_v_alias / canonical_umlaut_spelling,替换 canonical_syllable 与 to_google_spelling 里各自手抄的别名表,normalize_umlaut_aliases 也改用它。 - 纠错表生成器与运行时生成式空间不再从 jqxy+v 别名派生纠错键(nvan -> jvan 之类), 手误只纠到 u 的标准写法;重新生成 autocorrect_table.h。 - 个人词库新写入的拼音词、设置页导入的全拼按词库写法入库(xvan -> xuan、lue -> lve), 否则查询归一后永远查不到;被替换的旧词保留原键,旧行仍可删除。 - 双拼音节集统一排除 jqxy+v 别名,round-trip 检查不再特判。 --------- Co-authored-by: fanlusky <1730976608@qq.com>
96 lines
4.0 KiB
C++
96 lines
4.0 KiB
C++
#pragma once
|
|
|
|
#include "../../core/input_session_types.h"
|
|
#include "../../core/runtime_paths.h"
|
|
#include "../../shuangpin/shuangpin_profile.h"
|
|
#include "../../core/fuzzy_pinyin_options.h"
|
|
#include <memory>
|
|
|
|
namespace metasequoia
|
|
{
|
|
struct SessionOptions
|
|
{
|
|
RuntimePaths paths;
|
|
SchemeType scheme = SchemeType::Quanpin;
|
|
ShuangpinProfile shuangpin_profile = GetXiaoheShuangpinProfile();
|
|
std::string helpcode_schema = "lantian";
|
|
// Quanpin autocorrection type mask (quanpin::kAutocorrect* bits); 0 keeps the
|
|
// user's spelling untouched, which is the default for a fresh install.
|
|
unsigned autocorrect_types = 0;
|
|
bool helpcode = true;
|
|
bool chinese_punctuation = true;
|
|
bool learning = true;
|
|
FuzzyPinyinOptions fuzzy_pinyin;
|
|
FrequencyAdjustmentOptions frequency;
|
|
LocalModeOptions local_modes;
|
|
EnglishInputOptions english;
|
|
MixedExpressiveOptions expressive;
|
|
WubiInputOptions wubi;
|
|
};
|
|
|
|
struct SessionSnapshot
|
|
{
|
|
SchemeType scheme;
|
|
LocalInputMode local_mode;
|
|
std::string preedit;
|
|
std::string raw_segmentation;
|
|
std::string normalized_segmentation;
|
|
std::vector<WordItem> candidates;
|
|
bool dedicated_english = false;
|
|
// ASCII source text and offset, separate from rendered preedit (e.g. Japanese kana).
|
|
std::string editing_text;
|
|
std::size_t caret_position = 0;
|
|
};
|
|
|
|
// Stable platform entry point. One host serializes calls to its session; distinct sessions
|
|
// can run concurrently. Snapshots and online requests are values safe to hand to other threads.
|
|
// No SQLite, provider registry, raw key codes or mutable composition internals are exposed.
|
|
class Session
|
|
{
|
|
public:
|
|
explicit Session(SessionOptions options);
|
|
~Session();
|
|
Session(const Session &) = delete;
|
|
Session &operator=(const Session &) = delete;
|
|
|
|
KeyResult character(char value, bool shift_only = false);
|
|
KeyResult command(Command value);
|
|
KeyResult candidate_key(char value);
|
|
KeyResult punctuation(char value);
|
|
// Live host mode override; preserves composition, caret and punctuation pairing.
|
|
// When disabled punctuation() is unhandled; the host owns ASCII passthrough.
|
|
void set_chinese_punctuation_enabled(bool enabled);
|
|
KeyResult select(std::size_t index);
|
|
KeyResult select_edge(std::size_t index, CandidateEdge edge);
|
|
// Explicit user action: promote a dictionary candidate without committing input.
|
|
// Invalid/unsupported candidates are unhandled; persistence failures carry a diagnostic.
|
|
KeyResult pin(std::size_t index);
|
|
// Remove a dictionary phrase without committing; single-character non-English
|
|
// candidates are protected. Invalid/unsupported selections are unhandled.
|
|
KeyResult remove(std::size_t index);
|
|
// Fix a dictionary candidate to slot 1..5 in this input context, or clear it.
|
|
KeyResult fix_position(std::size_t index, int position);
|
|
KeyResult clear_position(std::size_t index);
|
|
KeyResult finish();
|
|
// Finish the whole composition, starting with the host-highlighted candidate.
|
|
// Remaining segments use their leading candidate; an invalid index commits raw input.
|
|
KeyResult finish(std::size_t first_index);
|
|
void switch_scheme(SchemeType scheme);
|
|
static bool is_supported_helpcode_schema(const std::string &schema);
|
|
bool set_helpcode_schema(const std::string &schema);
|
|
// Apply the same enable flag to quanpin and shuangpin, as SessionOptions::helpcode does.
|
|
// Hosts with per-scheme preferences apply the selected preference after switching.
|
|
void set_helpcode_enabled(bool enabled);
|
|
void set_dedicated_english(bool enabled);
|
|
// 五笔拼音混输:同一串字母同时交给五笔码表和全拼,五笔候选在前、拼音候选追加在后。
|
|
void set_wubi_mixed_pinyin(bool enabled);
|
|
SessionSnapshot snapshot() const;
|
|
std::optional<OnlineQuery> online_query() const;
|
|
bool apply_online_candidate(const OnlineQuery &query, std::string candidate, CandidateSource source);
|
|
|
|
private:
|
|
class Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
};
|
|
} // namespace metasequoia
|