Split mixed Chinese/English input without spaces; add release script

The classifier now segments a buffer into alternating Zhuyin and literal runs
by dynamic programming over split points, so "ji3hello" becomes 我hello and
"hellosu3cl3" becomes hello你好. Each switch costs a penalty, a Zhuyin run
followed by another must end with a tone, and an untoned trailing Zhuyin run
after English is penalized so partial words don't flicker into Bopomofo.
Implemented in both Swift and Python with the same tests; the Mac app colours
each segment separately.

scripts/bump-version.sh bumps the version in Info.plist and ime.json;
scripts/release.sh bumps, tests, packages, commits and tags in one step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 16:21:13 +08:00
co-authored by Claude Opus 5.5
parent dbe08e00a7
commit d1f1112c65
10 changed files with 482 additions and 97 deletions
+54
View File
@@ -0,0 +1,54 @@
#!/bin/bash
# One-step release: bump the version, run all tests, build both installers, then
# commit the version change and tag it.
#
# Usage: scripts/release.sh [patch|minor|major] [--push] (default: patch)
# --push also pushes the commit and tag to origin
set -euo pipefail
cd "$(dirname "$0")/.."
LEVEL=patch
PUSH=0
for arg in "$@"; do
case "$arg" in
patch|minor|major) LEVEL="$arg" ;;
--push) PUSH=1 ;;
*) echo "usage: $0 [patch|minor|major] [--push]" >&2; exit 2 ;;
esac
done
if [ -n "$(git status --porcelain)" ]; then
echo "Working tree has uncommitted changes; commit them first." >&2
exit 1
fi
export DEVELOPER_DIR="${DEVELOPER_DIR:-/Applications/Xcode.app/Contents/Developer}"
VERSION="$(scripts/bump-version.sh "$LEVEL")"
echo "==> Version $VERSION"
restore() {
echo "Release failed; reverting the version bump." >&2
git checkout -- Resources/Info.plist windows/autozhuyin/ime.json
}
trap restore ERR
echo "==> Swift tests"
xcrun swift test -q 2>&1 | tail -3
echo "==> Packaging (runs the Python tests too)"
scripts/package.sh >/dev/null
scripts/package-windows.sh >/dev/null
trap - ERR
git add Resources/Info.plist windows/autozhuyin/ime.json
git commit -q -m "Release v$VERSION"
git tag -a "v$VERSION" -m "AutoZhuyin v$VERSION"
echo "==> Tagged v$VERSION"
ls -lh "build/AutoZhuyin-$VERSION.pkg" "build/AutoZhuyin-Windows-$VERSION.zip"
shasum -a 256 "build/AutoZhuyin-$VERSION.pkg" "build/AutoZhuyin-Windows-$VERSION.zip"
if [ "$PUSH" = 1 ]; then
git push origin HEAD "v$VERSION"
else
echo "Push with: git push origin HEAD v$VERSION"
fi