Files
Lu Fan(SonnyCalcr) 3cd429b19d feat(server): 加入 S 模式符号输入与符号混输 (#1047)
符号数据改用 rime-wanxiang 的符号表与 typst/codex 符号名,源数据放在
msime-dictionary 的 sources/symbols/,替换原来的 piliapp 符号表。

- 建库:新增 symbols_db.py,生成表情面板用的 symbol_catalog(中文分类)和
  S 模式、符号混输用的 symbol_code;剔除 wanxiang-unrenderable.txt 列出的
  Windows 自带字体显示不了的符号,以及与 ① ❶ 看不出区别的 Dingbats 带圈数字
- 新增 scripts/check-symbol-rendering.py,用 Windows 字体生成上面的剔除清单
- Shift+S 进入符号模式,按万象分组码(xl、sx、szq)、数字读音(yi → 一 ① ⑴)
  或符号名(alpha、infinity)检索
- 符号混输:整串精确等于编码时混入,首个紧跟首选;读得成拼音的编码只混数字
  序号写法;双拼先按方案换算成全拼再查(小鹤 sj → san → ③)
- 表情面板符号页:中文分类,搜索把整词命中的符号列在「最佳匹配」
- 配置:utility.symbol_mode(默认开)、general.symbol_mixed_input(默认关)

Refs #795
2026-10-18 02:08:39 +08:00

75 lines
3.8 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "scheme_type.h"
#include <string>
#include <cstdint>
#include <utility>
enum class CandidateSource
{
Database,
UserDatabase,
CloudSuggestion,
AiSuggestion,
EnglishDictionary,
QuickPhrase,
Emoji,
Kaomoji,
Generated,
Fallback,
// 神经整句重排挑中的那一条:句子本身还是词格解出来的 n-best,chinese-ime-lm 的字符级
// Transformer 只负责在里面挑最准的一句,挑中的那行记在这里,词格自己的第一名仍记
// Generated。重排器弃权或后台还没算完时不会出现这两个来源。desktop 档更准更慢,
// keyboard 档更快。两者都属于「猜出来的整句」,落库/学习判定与 Generated/Fallback 同类。
NeuralDesktop,
NeuralKeyboard,
// 全拼/双拼里打 rq / sj / xq 等唤醒词时混进普通候选的日期、时间、星期。Shift+T 模式里的同一批
// 文本仍记 Generated:那是独占的候选列表,不和别的候选排位置。
DateTime,
// 万象语法模型(octagram .gram)在词格 n-best 上重排挑中的那一句。句子仍是词格
// 解出来的,搭配强度表只负责挑;落库/学习判定与 NeuralDesktop/NeuralKeyboard 同类。
Collocation,
// Shift+S 符号模式与符号混输查出的符号(others.db 的 symbol_code)。与 emoji 一样直接上屏,
// 不进词库、不调频。
Symbol,
};
struct WordItem
{
// The input code matched by this candidate. This remains scheme/raw-input
// oriented because composition advancement must consume exactly what the
// user typed (including abbreviated pinyin).
std::string pinyin;
// The complete quanpin key read from the database. It is deliberately
// separate from pinyin: abbreviated quanpin and shuangpin candidates use
// their typed code for advancement, but phrase creation must persist a
// complete, unambiguous pronunciation.
std::string canonical_pinyin;
std::string word;
std::int64_t weight = 0;
CandidateSource source = CandidateSource::Database;
// 产出该候选的输入方案。五笔拼音混输时同一个组合里既有五笔码表候选又有拼音候选,
// 调频、删除、固定位置和上屏后的组合推进都必须按候选自己的方案走,不能按会话方案
// 一刀切。默认 Quanpin:拼音、英文、云、本地模式候选共用拼音侧的读写路径,只有
// 五笔与日语候选需要显式标成自己的方案。
SchemeType scheme = SchemeType::Quanpin;
int fixed_position = 0;
bool fuzzy = false; // Matched typed code may differ from canonical pronunciation.
// 非空表示该候选来自纠错解释(scheme 别名层或纠错表改写了输入字母),值为纠错前的
// 原始输入字母串(对标 librime tips / 搜狗纠错标记)。填充规则见
// QuanpinDictionary::mark_autocorrect_candidates;前端仅据非空与否附加轻标记。
std::string corrected_from;
// 只有整句联想(Google 解码器的 Fallback、kenlm 词格的 Generated)产出的那一行才置位。
// Generated/Fallback 同时被原样上屏、英文、日期、拆字、假名、译文等合成候选借用,
// 候选窗的〔Trigram〕/〔Unigram〕来源标签只认这个标记,不能单凭 source 判断。
bool sentence_association = false;
WordItem() = default;
WordItem(std::string pinyin_value, std::string word_value, std::int64_t weight_value,
CandidateSource source_value = CandidateSource::Database, std::string canonical_pinyin_value = {})
: pinyin(std::move(pinyin_value)), canonical_pinyin(std::move(canonical_pinyin_value)),
word(std::move(word_value)), weight(weight_value), source(source_value)
{
}
};