Skip to content

Commit b422f3e

Browse files
chore: finalized purification and stabilization pipeline
1 parent 367b20e commit b422f3e

5 files changed

Lines changed: 46 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
paths:
77
- 'scheme/**'
88
- 'lua/**'
9+
- 'dicts/**'
910
- 'rime.lua'
1011
workflow_dispatch:
1112

@@ -34,6 +35,22 @@ jobs:
3435
# Copy Lua engine (Crucial for functionality)
3536
cp -r lua dist/scheme/
3637
cp rime.lua dist/scheme/
38+
39+
# Unified Dictionary Consolidation (Merging Core and Thematic dicts)
40+
mkdir -p dist/scheme/dicts
41+
42+
# 1. Copy core dictionaries from scheme/shared/core/dicts
43+
if [ -d "scheme/shared/core/dicts" ]; then
44+
cp scheme/shared/core/dicts/*.dict.yaml dist/scheme/dicts/ 2>/dev/null || true
45+
fi
46+
47+
# 2. Copy thematic dictionaries from root dicts/ folder
48+
if [ -d "dicts" ]; then
49+
cp -r dicts/* dist/scheme/dicts/ 2>/dev/null || true
50+
fi
51+
52+
# Cleanup: ensure no original wanxiang-branded files leaked (safety check)
53+
find dist/scheme -type f -name "wanxiang*" -delete
3754
3855
cd dist
3956
tar -czf scheme.tar.gz scheme/

.github/workflows/sync-upstream.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,37 @@ jobs:
3535
run: |
3636
git clone --depth 1 https://github.com/amzxyz/rime_wanxiang.git /tmp/core
3737
38-
# 1. Sync Scheme YAMLs
39-
mkdir -p scheme/shared/core
38+
# 1. Sync Scheme YAMLs & Dictionaries
39+
mkdir -p scheme/shared/core/dicts
4040
cp /tmp/core/wanxiang.schema.yaml scheme/shared/core/core.schema.yaml
4141
cp /tmp/core/wanxiang_algebra.yaml scheme/shared/core/core_algebra.yaml
4242
cp /tmp/core/wanxiang_symbols.yaml scheme/shared/core/core_symbols.yaml
43-
cp /tmp/core/wanxiang_english.dict.yaml scheme/shared/core/core_english.dict.yaml
44-
cp /tmp/core/wanxiang_mixedcode.dict.yaml scheme/shared/core/core_mixedcode.dict.yaml
45-
cp /tmp/core/wanxiang_reverse.dict.yaml scheme/shared/core/core_reverse.dict.yaml
43+
44+
# Sync core dictionaries (Crucial for engine functionality)
45+
cp /tmp/core/wanxiang_english.dict.yaml scheme/shared/core/dicts/core_english.dict.yaml
46+
cp /tmp/core/wanxiang_mixedcode.dict.yaml scheme/shared/core/dicts/core_mixedcode.dict.yaml
47+
cp /tmp/core/wanxiang_reverse.dict.yaml scheme/shared/core/dicts/core_reverse.dict.yaml
4648
cp /tmp/core/wanxiang_reverse.schema.yaml scheme/shared/core/core_reverse.schema.yaml
4749
50+
# Sync all other core dictionary files
51+
cp /tmp/core/*.dict.yaml scheme/shared/core/dicts/ 2>/dev/null || true
52+
53+
# Apply purification to internal dictionary names
54+
find scheme/shared/core/dicts -name "*.dict.yaml" -type f -exec sed -i 's/wanxiang/core/g' {} +
55+
find scheme/shared/core/dicts -name "*.dict.yaml" -type f -exec sed -i 's/万象/核心/g' {} +
56+
4857
# 2. Sync Lua Logic & Purify
4958
rm -rf lua/core lua/data
5059
mkdir -p lua/core lua/data
5160
cp -r /tmp/core/lua/wanxiang/. lua/core/
5261
cp -r /tmp/core/lua/data/. lua/data/
5362
mv lua/core/wanxiang.lua lua/core/core.lua
5463
55-
# Apply branding purification to Lua
64+
# Apply branding purification to Lua & YAML content (Deep Purification)
5665
find lua/core -name "*.lua" -type f -exec sed -i 's/wanxiang/core/g' {} +
5766
find lua/core -name "*.lua" -type f -exec sed -i 's/万象/核心/g' {} +
67+
find scheme/shared/core -name "*.yaml" -type f -exec sed -i 's/wanxiang/core/g' {} +
68+
find scheme/shared/core -name "*.yaml" -type f -exec sed -i 's/万象/核心/g' {} +
5869
5970
# 3. Generate Purified rime.lua
6071
cat <<EOF > rime.lua

scheme/shared/gins.dict.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import_tables:
1414
- dicts/renming
1515
- dicts/wuzhong
1616
- dicts/cn&en
17-
- zhwiki
18-
- tone_moe
19-
- gins-shici
17+
- dicts/zhwiki
18+
- dicts/tone_moe
19+
- dicts/gins-shici
2020
...

tools/gins-rime-cli/Sources/GinsRime/Commands/Status.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ struct Status: AsyncParsableCommand {
3232
("dicts/wuzhong.dict.yaml", "wuzhong 物种"),
3333
]
3434
let externalDicts: [(String, String)] = [
35-
("tone_moe.dict.yaml", "tone_moe 萌娘百科"),
36-
("zhwiki.dict.yaml", "zhwiki 维基百科标题"),
37-
("gins-shici.dict.yaml", "gins-shici 古诗词补充"),
35+
("dicts/tone_moe.dict.yaml", "tone_moe 萌娘百科"),
36+
("dicts/zhwiki.dict.yaml", "zhwiki 维基百科标题"),
37+
("dicts/gins-shici.dict.yaml", "gins-shici 古诗词补充"),
3838
]
3939

40-
print("万象内置词库:")
40+
print("核心内置词库:")
4141
for (file, label) in builtinDicts {
4242
let exists = fm.fileExists(atPath: rimeDir.appendingPathComponent(file).path)
4343
print(" \(exists ? "" : "") \(label)")
@@ -47,7 +47,7 @@ struct Status: AsyncParsableCommand {
4747
let versions = loadVersions()
4848
for (file, label) in externalDicts {
4949
let exists = fm.fileExists(atPath: rimeDir.appendingPathComponent(file).path)
50-
let dictName = file.replacingOccurrences(of: ".dict.yaml", with: "")
50+
let dictName = file.replacingOccurrences(of: "dicts/", with: "").replacingOccurrences(of: ".dict.yaml", with: "")
5151
let ver = versions[dictName].map { " (\($0))" } ?? ""
5252
print(" \(exists ? "" : "") \(label)\(ver)")
5353
}

tools/gins-rime-cli/Sources/GinsRime/Commands/Update.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ struct Update: AsyncParsableCommand {
111111

112112
private func downloadDict(_ name: String) async throws {
113113
let url = URL(string: "\(GinsSettings.workerBase)/dicts/\(name)")!
114-
let dest = RimePaths.user.appendingPathComponent("\(name).dict.yaml")
114+
let dictsDir = RimePaths.user.appendingPathComponent("dicts")
115+
try FileManager.default.createDirectory(at: dictsDir, withIntermediateDirectories: true)
116+
117+
let dest = dictsDir.appendingPathComponent("\(name).dict.yaml")
115118
let (tmp, _) = try await URLSession.shared.download(from: url)
116119
if FileManager.default.fileExists(atPath: dest.path) {
117120
try FileManager.default.removeItem(at: dest)

0 commit comments

Comments
 (0)