mirror of
https://github.com/d0zingcat/rime_wanxiang.git
synced 2026-05-14 07:26:45 +00:00
chore:新的根节点
This commit is contained in:
197
.github/workflows/scripts/aux_go.py
vendored
Normal file
197
.github/workflows/scripts/aux_go.py
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
# ---------- 在第一个点前插入后缀(例:base.dict.yaml -> base.pro.dict.yaml) ----------
|
||||
def add_suffix_before_extensions(filename: str, suffix: str) -> str:
|
||||
if not suffix:
|
||||
return filename
|
||||
i = filename.find('.')
|
||||
return (filename + suffix) if i == -1 else (filename[:i] + suffix + filename[i:])
|
||||
|
||||
# ========== 1) 从“单个 aux 文件”加载 字 -> 辅助码段列表 ==========
|
||||
# 行格式:字<TAB>;段1;段2;... (保留空段,不偏移;段内逗号原样保留)
|
||||
def load_aux_table(aux_file_path):
|
||||
if not os.path.isfile(aux_file_path):
|
||||
raise FileNotFoundError(f"aux 文件不存在:{aux_file_path}")
|
||||
aux_map = {}
|
||||
print(f'加载辅助码表文件: {os.path.basename(aux_file_path)}')
|
||||
with open(aux_file_path, 'r', encoding='utf-8') as f:
|
||||
for raw in f:
|
||||
line = raw.strip()
|
||||
if not line or line.startswith('#'):
|
||||
continue
|
||||
parts = line.split('\t')
|
||||
if len(parts) < 2:
|
||||
continue
|
||||
ch = parts[0]
|
||||
aux_list = parts[1].split(';') # 保留空串占位(分号才是边界)
|
||||
aux_map[ch] = aux_list
|
||||
return aux_map
|
||||
|
||||
# ========== 2) 区间选择(严格:第 N 段 = aux_list[N];N 从 1 起)==========
|
||||
# 不处理逗号:分号窗口原样拼接
|
||||
def select_aux_segment(aux_list, start_idx, end_idx=None):
|
||||
if not aux_list:
|
||||
return ''
|
||||
s = max(1, start_idx)
|
||||
e = end_idx if end_idx is not None else len(aux_list)
|
||||
e = max(s, min(e, len(aux_list)))
|
||||
window = aux_list[s:e] # 允许空段
|
||||
return ''.join(window) if window else ''
|
||||
|
||||
DIGIT_RE = re.compile(r'^\d+$')
|
||||
|
||||
# ========== 3) 处理单个词库(流式;空也占位“拼音;”)==========
|
||||
def process_file_for_range_streaming(in_file, out_file, aux_map, start_idx, end_idx, sep=';'):
|
||||
os.makedirs(os.path.dirname(out_file), exist_ok=True)
|
||||
try:
|
||||
fin = open(in_file, 'r', encoding='utf-8')
|
||||
except Exception as e:
|
||||
print(f'读取失败 {in_file}: {e}')
|
||||
return
|
||||
try:
|
||||
fout = open(out_file, 'w', encoding='utf-8')
|
||||
except Exception as e:
|
||||
fin.close()
|
||||
print(f'写入失败 {out_file}: {e}')
|
||||
return
|
||||
|
||||
passthrough_set = {
|
||||
"的\td\t1000",
|
||||
"了\tl\t999",
|
||||
"吗\tm\t999",
|
||||
"吧\tb\t999",
|
||||
}
|
||||
|
||||
processing = False
|
||||
for line in fin:
|
||||
if not processing:
|
||||
fout.write(line)
|
||||
if '...' in line:
|
||||
processing = True
|
||||
continue
|
||||
|
||||
raw = line.rstrip('\n')
|
||||
if (not raw) or raw.lstrip().startswith('#'):
|
||||
fout.write(line)
|
||||
continue
|
||||
|
||||
parts = raw.split('\t')
|
||||
if len(parts) == 1:
|
||||
fout.write(line)
|
||||
continue
|
||||
|
||||
han = parts[0]
|
||||
col2 = parts[1] if len(parts) > 1 else ''
|
||||
col3 = parts[2] if len(parts) > 2 else ''
|
||||
col4 = parts[3] if len(parts) > 3 else ''
|
||||
|
||||
# 第二列若是频率(全数字),挪到第三列
|
||||
if DIGIT_RE.fullmatch(col2 or ''):
|
||||
col3, col2 = col2, ''
|
||||
|
||||
# 特定行直通
|
||||
if raw.strip() in passthrough_set:
|
||||
fout.write(raw + '\n')
|
||||
continue
|
||||
|
||||
pinyins = col2.split(' ') if col2 else []
|
||||
if len(pinyins) != len(han):
|
||||
warn = f"# 警告: 拼音数与字数不匹配({in_file}) => {raw}"
|
||||
print(warn)
|
||||
fout.write(warn + '\n')
|
||||
continue
|
||||
|
||||
_get = aux_map.get
|
||||
new_cols = []
|
||||
for i, ch in enumerate(han):
|
||||
aux_list = _get(ch)
|
||||
piece = select_aux_segment(aux_list, start_idx, end_idx) if aux_list is not None else ''
|
||||
new_cols.append(pinyins[i] + sep + piece) # 空也占位:拼音;片段
|
||||
|
||||
new_col2 = ' '.join(new_cols)
|
||||
if col4:
|
||||
fout.write(f"{han}\t{new_col2}\t{col3}\t{col4}\n" if col3 else f"{han}\t{new_col2}\t\t{col4}\n")
|
||||
else:
|
||||
fout.write(f"{han}\t{new_col2}\t{col3}\n" if col3 else f"{han}\t{new_col2}\n")
|
||||
|
||||
fin.close()
|
||||
fout.close()
|
||||
print(f'已处理: {out_file}')
|
||||
|
||||
# ========== 4) 扫目录 + 六套区间(按白名单)==========
|
||||
def process_batch(input_dir, aux_file_path, base_out_dir, index_mapping, files_whitelist=None,
|
||||
sep=';', output_suffix=""):
|
||||
aux_map = load_aux_table(aux_file_path)
|
||||
print(f'已加载辅助码条目:{len(aux_map)}')
|
||||
|
||||
# 收集要处理的文件
|
||||
to_process = []
|
||||
for entry in os.scandir(input_dir):
|
||||
if not entry.is_file():
|
||||
continue
|
||||
name = entry.name
|
||||
if files_whitelist and name not in files_whitelist:
|
||||
continue
|
||||
if not (name.endswith('.yaml') or name.endswith('.yml') or name.endswith('.txt')):
|
||||
continue
|
||||
to_process.append(entry.path)
|
||||
|
||||
if not to_process:
|
||||
print("输入目录内没有匹配文件")
|
||||
return
|
||||
|
||||
for s_idx, e_idx, subdir in index_mapping:
|
||||
out_dir = os.path.join(base_out_dir, subdir)
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
print(f'\n=== 区间 ({s_idx}, {e_idx}) → {subdir} ===')
|
||||
for in_file in to_process:
|
||||
fn = os.path.basename(in_file)
|
||||
out_name = add_suffix_before_extensions(fn, output_suffix)
|
||||
out_file = os.path.join(out_dir, out_name)
|
||||
process_file_for_range_streaming(in_file, out_file, aux_map, s_idx, e_idx, sep=sep)
|
||||
|
||||
# ========== 5) 入口 ==========
|
||||
if __name__ == '__main__':
|
||||
# 六套区间(第 N 段,从 1 起)
|
||||
index_mapping = [
|
||||
(1, 2, "pro-moqi-fuzhu-dicts"),
|
||||
(2, 3, "pro-flypy-fuzhu-dicts"),
|
||||
(3, 4, "pro-zrm-fuzhu-dicts"),
|
||||
(4, 5, "pro-tiger-fuzhu-dicts"),
|
||||
(5, 6, "pro-wubi-fuzhu-dicts"),
|
||||
(6, 7, "pro-hanxin-fuzhu-dicts"),
|
||||
(7, None, "pro-shouyou-fuzhu-dicts"),
|
||||
]
|
||||
|
||||
# 路径
|
||||
AUX_FILE = "custom/aux_code.txt" # ← 单个 aux 文件
|
||||
INPUT_DIR = "dicts" # ← 词库文件夹
|
||||
OUT_ROOT = "." # ← 输出根目录
|
||||
|
||||
# 仅处理这些文件
|
||||
FILES = [
|
||||
"jichu.dict.yaml",
|
||||
"zi.dict.yaml",
|
||||
"duoyin.dict.yaml",
|
||||
"cuoyin.dict.yaml",
|
||||
"diming.dict.yaml",
|
||||
"shici.dict.yaml",
|
||||
"lianxiang.dict.yaml",
|
||||
"renming.dict.yaml",
|
||||
"wuzhong.dict.yaml",
|
||||
"shuxue.dict.yaml",
|
||||
"dikuang.dict.yaml",
|
||||
"wu-hua-sheng-yi-yao.dict.yaml",
|
||||
]
|
||||
|
||||
# 输出文件在第一个点前插这个后缀(如 ".pro";设为空串则不加)
|
||||
OUTPUT_SUFFIX = ".pro"
|
||||
|
||||
process_batch(
|
||||
INPUT_DIR, AUX_FILE, OUT_ROOT,
|
||||
index_mapping,
|
||||
files_whitelist=FILES,
|
||||
sep=';',
|
||||
output_suffix=OUTPUT_SUFFIX
|
||||
)
|
||||
78
.github/workflows/scripts/generate-release-note.sh
vendored
Normal file
78
.github/workflows/scripts/generate-release-note.sh
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# 声明辅助码 zip 包类型显示名
|
||||
declare -A display_names=(
|
||||
[zrm]="自然码"
|
||||
[moqi]="墨奇"
|
||||
[flypy]="小鹤"
|
||||
[hanxin]="汉心"
|
||||
[wubi]="五笔前2"
|
||||
[tiger]="虎码首末"
|
||||
[shouyou]="首右"
|
||||
)
|
||||
|
||||
# 仓库和下载地址定义
|
||||
REPO_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
|
||||
DOWNLOAD_URL=${REPO_URL}/releases/download/${TAG_VERSION}
|
||||
|
||||
# 获取 changelog(标题相同的 commit 合并链接)
|
||||
CHANGES=$(
|
||||
gh release view --json body -t "{{.body}}" "${TAG_VERSION}" | sed '1d; /./,$!d'
|
||||
)
|
||||
|
||||
{
|
||||
echo "## 📝 更新日志"
|
||||
echo ""
|
||||
echo "${CHANGES}"
|
||||
echo ""
|
||||
echo "## 🚀 下载引导"
|
||||
echo ""
|
||||
echo "### 1. 标准版输入方案"
|
||||
echo ""
|
||||
echo "✨**适用类型:** 支持全拼、各种双拼"
|
||||
echo ""
|
||||
echo "✨**下载地址:** [rime-wanxiang-base.zip](${DOWNLOAD_URL}/rime-wanxiang-base.zip)"
|
||||
echo ""
|
||||
echo "### 2. 双拼辅助码增强版输入方案"
|
||||
echo ""
|
||||
echo "✨**适用类型:** 支持各种双拼+辅助码的自由组合"
|
||||
|
||||
for type in "${!display_names[@]}"; do
|
||||
name="${display_names[$type]}"
|
||||
echo " - **${name}辅助版本:** [rime-wanxiang-${type}-fuzhu.zip](${DOWNLOAD_URL}/rime-wanxiang-${type}-fuzhu.zip)"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "### 3. 语法模型"
|
||||
echo ""
|
||||
echo "✨**适用类型:** 所有版本皆可用"
|
||||
echo ""
|
||||
echo "✨**下载地址:** [wanxiang-lts-zh-hans.gram](https://github.com/amzxyz/RIME-LMDG/releases/download/LTS/wanxiang-lts-zh-hans.gram)"
|
||||
echo ""
|
||||
echo "## 📘 使用说明(QQ群:11033572 参与讨论)"
|
||||
echo ""
|
||||
echo "1. **不使用辅助码的用户:**"
|
||||
echo ""
|
||||
echo " 请直接下载标准版,按仓库中的 [README.md](${REPO_URL}/blob/wanxiang/README.md) 配置使用。"
|
||||
echo ""
|
||||
echo "2. **使用增强版的用户:**"
|
||||
echo " - PRO 每一个 zip 是**完整独立配置包**,其差异仅在于词库是否带有特定辅助码。"
|
||||
echo ' - zrm 仅表示“词库中包含zrm辅助码”,并**不代表这是自然码双拼方案,万象支持任意双拼与任意辅助码组合使用**。'
|
||||
echo " - 若已有目标辅助码类型,只需下载对应 zip,解压后根据 README 中提示修改表头(例如双拼方案)即可使用。"
|
||||
echo ""
|
||||
echo "3. **语法模型需单独下载**,并放入输入法用户目录根目录(与方案文件放一起),**无需配置**。"
|
||||
echo ""
|
||||
echo "4. 💾 飞机盘下载地址(最快更新):[点击访问](https://share.feijipan.com/s/xiGvXdKz)"
|
||||
echo ""
|
||||
echo "5. Arch Linux 用户推荐 [启用 Arch Linux CN 仓库](https://www.archlinuxcn.org/archlinux-cn-repo-and-mirror/) 或通过 [AUR](https://aur.archlinux.org/pkgbase/rime-wanxiang),按需安装。"
|
||||
echo " - 基础版包名:\`rime-wanxiang-[拼写方案名]\`,如:自然码方案:\`rime-wanxiang-zrm\`"
|
||||
echo " - 双拼辅助码增强版包名:\`rime-wanxiang-pro-[拼写方案名]\`,如:自然码方案:\`rime-wanxiang-pro-zrm\`"
|
||||
echo "6. Deepin Linux v25 用户亦可以通过仓库进行安装。"
|
||||
echo "### 4. 周边推荐"
|
||||
echo " - [高度适配万象拼音的仓输入法皮肤](https://github.com/BlackCCCat/ResourceforHamster/tree/main/Skin_Keyboard/)"
|
||||
echo ""
|
||||
echo " - [好用的更新脚本,助你优雅管理版本](https://github.com/rimeinn/rime-wanxiang-update-tools)"
|
||||
echo ""
|
||||
echo " - [万象cnb仓库,无需梯子的类GitHub仓库国内平台](https://cnb.cool/amzxyz/rime-wanxiang)"
|
||||
} >release_notes.md
|
||||
152
.github/workflows/scripts/release-build.sh
vendored
Normal file
152
.github/workflows/scripts/release-build.sh
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
#!/bin/bash
|
||||
# 打包对用方案到 zip 文件,放到 dist 目录
|
||||
set -e
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/../../../" && pwd)"
|
||||
DIST_DIR="$ROOT_DIR/dist"
|
||||
CUSTOM_DIR="$ROOT_DIR/custom"
|
||||
|
||||
# 成成 PRO 分包文件
|
||||
echo "▶️ PRO 分包开始"
|
||||
python3 "$ROOT_DIR/.github/workflows/scripts/aux_go.py"
|
||||
echo "✅ PRO 分包完毕"
|
||||
echo
|
||||
|
||||
package_schema_base() {
|
||||
OUT_DIR=$1
|
||||
rm -rf "$OUT_DIR"
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
# 1) custom/:仅拷贝 yaml/md/jpg/png,排除指定文件(保留目录结构)
|
||||
mkdir -p "$OUT_DIR/custom"
|
||||
rsync -av --prune-empty-dirs \
|
||||
--include='*/' \
|
||||
--exclude='wanxiang_chaifen_*.dict.yaml' \
|
||||
--exclude='wanxiang_chaifen.schema.yaml' \
|
||||
--exclude='wanxiang_pro.custom.yaml' \
|
||||
--exclude='wanxiang_pro.dict.yaml' \
|
||||
--exclude='wanxiang_pro.schema.yaml' \
|
||||
--include='*.yaml' --include='*.md' --include='*.jpg' --include='*.png' \
|
||||
--exclude='*' \
|
||||
"$CUSTOM_DIR/" "$OUT_DIR/custom/"
|
||||
|
||||
# 2) 根目录 → $OUT_DIR(不排 dicts/),排除若干
|
||||
OUT_BASE="$(basename "$OUT_DIR")"
|
||||
rsync -av --ignore-existing \
|
||||
--exclude='/.*' \
|
||||
--exclude='/dist/' \
|
||||
--exclude='/release-please-config.json' \
|
||||
--exclude='/pro-*-fuzhu-dicts' \
|
||||
--exclude='/chaifen' \
|
||||
--exclude='/CHANGELOG.md' \
|
||||
--exclude='/custom' \
|
||||
--exclude='/LICENSE' \
|
||||
--exclude="/$OUT_BASE" \
|
||||
"$ROOT_DIR/" "$OUT_DIR/"
|
||||
}
|
||||
|
||||
package_schema_pro() {
|
||||
SCHEMA_NAME="$1"
|
||||
OUT_DIR="$2"
|
||||
rm -rf "$OUT_DIR"
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
# 1) 移动分包后的 dicts
|
||||
if [[ -d "$ROOT_DIR/pro-$SCHEMA_NAME-fuzhu-dicts" ]]; then
|
||||
mv "$ROOT_DIR/pro-$SCHEMA_NAME-fuzhu-dicts" "$OUT_DIR/dicts"
|
||||
fi
|
||||
# 1.1) 补充必要的附加文件
|
||||
for f in en.dict.yaml "cn&en.dict.yaml" chengyu.txt people.dict.yaml; do
|
||||
if [[ -f "$ROOT_DIR/dicts/$f" ]]; then
|
||||
cp "$ROOT_DIR/dicts/$f" "$OUT_DIR/dicts/"
|
||||
fi
|
||||
done
|
||||
|
||||
# 2) 复制拆分表并重命名,同时拷贝 schema
|
||||
src="$ROOT_DIR/custom/wanxiang_chaifen_${SCHEMA_NAME}.dict.yaml"
|
||||
dst="$OUT_DIR/wanxiang_chaifen.dict.yaml"
|
||||
[[ -f "$src" ]] && cp "$src" "$dst"
|
||||
|
||||
for f in \
|
||||
wanxiang_pro.dict.yaml \
|
||||
wanxiang_pro.schema.yaml \
|
||||
wanxiang_chaifen.schema.yaml
|
||||
do
|
||||
src="$ROOT_DIR/custom/$f"
|
||||
dst="$OUT_DIR/$f"
|
||||
[[ -f "$src" ]] && cp "$src" "$dst"
|
||||
done
|
||||
|
||||
# 3) custom/:仅拷贝 yaml/md/jpg/png,排除若干(保留目录结构)
|
||||
mkdir -p "$OUT_DIR/custom"
|
||||
rsync -av --prune-empty-dirs \
|
||||
--include='*/' \
|
||||
--exclude='wanxiang.custom*' \
|
||||
--exclude='wanxiang_chaifen_*.dict.yaml' \
|
||||
--exclude='wanxiang_chaifen.schema.yaml' \
|
||||
--exclude='wanxiang_pro.dict.yaml' \
|
||||
--exclude='wanxiang_pro.schema.yaml' \
|
||||
--include='*.yaml' --include='*.md' --include='*.jpg' --include='*.png' \
|
||||
--exclude='*' \
|
||||
"$ROOT_DIR/custom/" "$OUT_DIR/custom/"
|
||||
|
||||
# 4) 根目录 → $OUT_DIR(排除若干)
|
||||
OUT_BASE="$(basename "$OUT_DIR")"
|
||||
rsync -av --ignore-existing \
|
||||
--exclude='/.*' \
|
||||
--exclude='/dist/' \
|
||||
--exclude='/dicts' \
|
||||
--exclude='release-please-config.json' \
|
||||
--exclude='pro-*-fuzhu-dicts' \
|
||||
--exclude='wanxiang_t9.schema.yaml' \
|
||||
--exclude='CHANGELOG.md' \
|
||||
--exclude='wanxiang.dict.yaml' \
|
||||
--exclude='wanxiang.schema.yaml' \
|
||||
--exclude='custom' \
|
||||
--exclude='LICENSE' \
|
||||
--exclude="/$OUT_BASE" \
|
||||
"$ROOT_DIR/" "$OUT_DIR/"
|
||||
|
||||
# 5) default.yaml: - schema: wanxiang -> - schema: wanxiang_pro
|
||||
sed -i -E 's/^([[:space:]]*)-\s*schema:\s*wanxiang\s*$/\1- schema: wanxiang_pro/' "$OUT_DIR/default.yaml"
|
||||
}
|
||||
|
||||
|
||||
|
||||
package_schema() {
|
||||
SCHEMA_NAME="$1"
|
||||
echo "▶️ 开始打包方案:$SCHEMA_NAME"
|
||||
|
||||
if [[ "$SCHEMA_NAME" == "base" ]]; then
|
||||
OUT_DIR="$DIST_DIR/rime-wanxiang-base"
|
||||
package_schema_base "$OUT_DIR"
|
||||
|
||||
ZIP_NAME=rime-wanxiang-"$SCHEMA_NAME".zip
|
||||
else
|
||||
OUT_DIR="$DIST_DIR/rime-wanxiang-$SCHEMA_NAME-fuzhu"
|
||||
package_schema_pro "$SCHEMA_NAME" "$OUT_DIR"
|
||||
|
||||
fi
|
||||
|
||||
ZIP_NAME=$(basename "$OUT_DIR").zip
|
||||
(cd "$OUT_DIR" && zip -r -9 -q ../"$ZIP_NAME" . && cd ..)
|
||||
echo "✅ 完成打包: $ZIP_NAME"
|
||||
echo
|
||||
}
|
||||
|
||||
SCHEMA_LIST=("base" "flypy" "hanxin" "moqi" "tiger" "wubi" "zrm" "shouyou")
|
||||
|
||||
# 如果没有传入参数,则循环 package 所有的
|
||||
if [[ -z "$SCHEMA_NAME" ]]; then
|
||||
for name in "${SCHEMA_LIST[@]}"; do
|
||||
package_schema "$name"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! " ${SCHEMA_LIST[*]} " =~ ${SCHEMA_NAME} ]]; then
|
||||
echo "参数错误: 只支持 ${SCHEMA_LIST[*]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
package_schema "$SCHEMA_NAME"
|
||||
Reference in New Issue
Block a user