Skip to content

Commit b81580e

Browse files
authored
chore(assets): jieba 词典 gzip 化 + 删未压缩 models-dev 目录(-7.4MB) (#22)
Two zero-cost APK size wins (~7.4MB) found by benchmarking against taixu / OmniBot (docs/analysis-apk-size-vs-taixu-omnibot.md): - models-dev-api.json (4.1MB): the app reads the .gzip copy first and the plaintext file was only a gunzip-failure fallback — for a local asset that means a corrupt APK, and the network refresh is the real fallback. Asset, code fallback branch, and the update script's plaintext output all removed. The catalog guard test now verifies the gzip itself is readable and still carries the known-majority providers instead of diffing two copies. - jieba dictionaries (5.4MB → 2.1MB): jieba.dict.utf8 and hmm_model are now gzipped in assets and gunzipped onto filesDir at extract time; the native side keeps reading the plain file names, so jieba_jni.cpp is untouched. DICT_VERSION stays at 1 — content is unchanged and already-extracted copies remain valid. Co-authored-by: tall-1997 <278631348+tall-1997@users.noreply.github.com>
1 parent e6beebb commit b81580e

9 files changed

Lines changed: 44 additions & 349042 deletions

File tree

‎scripts/update_models_dev.sh‎

100755100644
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ set -euo pipefail
66

77
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
88
IOS_DEST="$SCRIPT_DIR/../src/ios/Resources/models-dev-api.json"
9-
ANDROID_DEST="$SCRIPT_DIR/../src/android/app/src/main/assets/models-dev-api.json"
10-
# Android's asset merger strips the .gz suffix and would collide with the
11-
# plaintext fallback. Use .gzip so both assets can coexist in the APK.
12-
ANDROID_GZ="${ANDROID_DEST}.gzip"
9+
# [T-apk-size] Android ships ONLY the gzipped catalog (~416KB vs 4.1MB
10+
# plaintext). The plaintext copy used to sit next to it as a fallback, but
11+
# the app reads the gzip first and a local asset failing to gunzip means a
12+
# corrupt APK — the network path is the real fallback.
13+
ANDROID_GZ="$SCRIPT_DIR/../src/android/app/src/main/assets/models-dev-api.json.gzip"
1314
URL="https://models.dev/api.json"
1415

1516
echo "Downloading $URL ..."

‎src/android/app/src/main/assets/jieba/hmm_model.utf8‎

Lines changed: 0 additions & 34 deletions
This file was deleted.
197 KB
Binary file not shown.

0 commit comments

Comments
 (0)