|
@@ -65,13 +65,17 @@ GITHUB_URL = (
|
|
|
DOWNLOAD_TIMEOUT = 60 # 秒
|
|
DOWNLOAD_TIMEOUT = 60 # 秒
|
|
|
CHUNK_SIZE = 1024 * 1024
|
|
CHUNK_SIZE = 1024 * 1024
|
|
|
|
|
|
|
|
-# 顺序与 Rust/Go 版本保持一致;只补充缺失项,不覆盖已有调参。
|
|
|
|
|
|
|
+# 集中维护万象模型参数;只补充缺失项,不覆盖用户已有调参。
|
|
|
PATCH_ITEMS = (
|
|
PATCH_ITEMS = (
|
|
|
("grammar/language", MODEL_NAME),
|
|
("grammar/language", MODEL_NAME),
|
|
|
- ("grammar/collocation_max_length", 5),
|
|
|
|
|
|
|
+ ("grammar/collocation_max_length", 6),
|
|
|
("grammar/collocation_min_length", 2),
|
|
("grammar/collocation_min_length", 2),
|
|
|
- ("translator/contextual_suggestions", True),
|
|
|
|
|
- ("translator/max_homophones", 7),
|
|
|
|
|
|
|
+ ("grammar/collocation_penalty", -14),
|
|
|
|
|
+ ("grammar/non_collocation_penalty", -6),
|
|
|
|
|
+ ("grammar/weak_collocation_penalty", -100),
|
|
|
|
|
+ ("grammar/rear_penalty", -18),
|
|
|
|
|
+ ("translator/contextual_suggestions", False),
|
|
|
|
|
+ ("translator/max_homophones", 8),
|
|
|
("translator/max_homographs", 7),
|
|
("translator/max_homographs", 7),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -368,6 +372,9 @@ def install(rime_dir: Path, timeout: float = DOWNLOAD_TIMEOUT) -> None:
|
|
|
added = []
|
|
added = []
|
|
|
for key, value in PATCH_ITEMS:
|
|
for key, value in PATCH_ITEMS:
|
|
|
if key not in patch:
|
|
if key not in patch:
|
|
|
|
|
+ if not added and len(patch) > 0:
|
|
|
|
|
+ # 无论 patch 中已有何种配置,新增万象配置前始终留一行空白。
|
|
|
|
|
+ patch.yaml_set_comment_before_after_key(key, before="\n")
|
|
|
patch[key] = value
|
|
patch[key] = value
|
|
|
added.append(key)
|
|
added.append(key)
|
|
|
|
|
|
|
@@ -384,7 +391,7 @@ def install(rime_dir: Path, timeout: float = DOWNLOAD_TIMEOUT) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
def uninstall(rime_dir: Path) -> None:
|
|
def uninstall(rime_dir: Path) -> None:
|
|
|
- """清理六个精确 patch 项和目标模型文件。"""
|
|
|
|
|
|
|
+ """清理万象 patch 项和目标模型文件。"""
|
|
|
_require_ruamel()
|
|
_require_ruamel()
|
|
|
rime_dir = Path(rime_dir).expanduser()
|
|
rime_dir = Path(rime_dir).expanduser()
|
|
|
_ensure_rime_dir(rime_dir)
|
|
_ensure_rime_dir(rime_dir)
|
|
@@ -393,10 +400,11 @@ def uninstall(rime_dir: Path) -> None:
|
|
|
config_path = rime_dir / CUSTOM_YAML_FILENAME
|
|
config_path = rime_dir / CUSTOM_YAML_FILENAME
|
|
|
model_path = rime_dir / MODEL_FILENAME
|
|
model_path = rime_dir / MODEL_FILENAME
|
|
|
|
|
|
|
|
- # 先解析并验证,配置不安全时绝不先删模型。
|
|
|
|
|
|
|
+ # 先解析配置,只有配置写入成功后才删除模型文件。
|
|
|
|
|
+ # 卸载时按键名清理整组万象参数,不检查当前值;用户手动调整过的
|
|
|
|
|
+ # 万象参数也必须一并删除。
|
|
|
root = _load_config(config_path)
|
|
root = _load_config(config_path)
|
|
|
patch = root.get("patch")
|
|
patch = root.get("patch")
|
|
|
- _ensure_no_other_model(patch, "卸载")
|
|
|
|
|
|
|
|
|
|
removed = []
|
|
removed = []
|
|
|
if patch is not None:
|
|
if patch is not None:
|