在完整音节后敲反引号,接着的字母筛这个音节上的字:第一码大小写均可, 紧跟的大写字母是第二码,之后可以接着打,一个输入里可以有多段。开关 helpcode.shuangpin_mid_sentence_helpcode 默认关闭。 约束在整句解码时生效,而不是解完再筛: - Google 解码器在 add_char_qwerty 里送 extend_mtrx_nd 之前按约束过滤词条, 锁住的字带着上下文重新整句解码;约束变化时整段重解,不污染增量搜索。 - kenlm 词格建图时按约束筛边,受约束的跨度不截断地查词库;神经重排只在 词格 n-best 里挑,自动满足约束。 - 普通词条、云和 AI 候选按同一规则收尾校验;满足不了就不出整句。 反引号段在请求里换成手动分隔符,原串留给宿主回读与预编辑显示;选词推进 时剩余音节上的约束随原串保留。输入形状规则放在 contracts/mid_sentence_helpcode.h, TSF、Server、引擎共用,新增 Worker opcode MidSentenceHelpcodeChanged = 28。 googlepinyinime-rev 已与上游解绑,AGENTS 与 UPSTREAM.md 同步说明。
55 lines
2.6 KiB
C++
55 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include "key_event.h"
|
|
#include "fuzzy_pinyin_options.h"
|
|
#include "scheme_type.h"
|
|
#include "sentence_association_options.h"
|
|
#include "syllable_helpcode.h"
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct KeyStroke
|
|
{
|
|
ImeKeyCode vk = 0;
|
|
ImeModifierMask modifiers_down = 0;
|
|
ImeCharacter wch = 0;
|
|
};
|
|
|
|
struct QueryRequest
|
|
{
|
|
SchemeType scheme = SchemeType::Quanpin;
|
|
std::string raw_input;
|
|
std::string raw_input_with_cases;
|
|
std::string normalized_input;
|
|
std::string raw_segmentation;
|
|
std::string normalized_segmentation;
|
|
std::string segmentation;
|
|
bool enable_shuangpin_helpcode = false;
|
|
bool enable_quanpin_helpcode = false;
|
|
// 句中辅助码,见 syllable_helpcode.h。输入串里带反引号段时,raw_input / raw_input_with_cases /
|
|
// 各切分都是把每段换成一个 ' 之后的结果,下游按普通手动分隔来切分、推进;原样的输入串放在
|
|
// raw_input_with_syllable_helpcodes,宿主回读输入串、显示预编辑时用它。没有反引号段时两者
|
|
// 都为空。syllable_helpcodes 不受开关影响(开关只管能不能敲进去),由开关决定是否参与筛选。
|
|
bool enable_mid_sentence_helpcode = false;
|
|
std::string raw_input_with_syllable_helpcodes;
|
|
SyllableHelpcodes syllable_helpcodes;
|
|
// Autocorrection is type-gated (bit0 transposition, bit1 neighbor in the session-level
|
|
// mask); both default off, so a fresh install never rewrites the user's spelling.
|
|
bool enable_quanpin_autocorrect_transposition = false;
|
|
bool enable_quanpin_autocorrect_neighbor = false;
|
|
std::vector<KeyStroke> key_strokes;
|
|
metasequoia::FuzzyPinyinOptions fuzzy_pinyin;
|
|
// 整句候选来源与去重补位选项,默认全关。
|
|
SentenceAssociationOptions sentence_association;
|
|
// 给神经重排看的前文:本会话最近上屏的文本。空着也能重排,只是模型看不到语境,「shanghai」
|
|
// 到底是上海还是伤害就只能靠词格自己的静态分。词典层只取末尾若干字(RerankOptions::
|
|
// context_chars),所以这里给多了也无妨。
|
|
std::string rescoring_context;
|
|
// Wubi wildcard mode and the code in hand holds a z: the provider matches the code as a
|
|
// pattern (z = one arbitrary letter) instead of a prefix range. Never set for other schemes.
|
|
// With mixed input also on, the same z is offered to pinyin as a plain letter and those
|
|
// candidates are placed ahead of the wildcard rows (see ImeSession::refresh_candidates).
|
|
bool wubi_z_wildcard = false;
|
|
bool valid = false;
|
|
};
|