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:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# Increments the version in every place it lives:
|
||||
# Resources/Info.plist CFBundleShortVersionString (x.y.z) and CFBundleVersion (build number)
|
||||
# windows/autozhuyin/ime.json "version"
|
||||
#
|
||||
# Usage: scripts/bump-version.sh [patch|minor|major] (default: patch)
|
||||
# Prints the new version.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
LEVEL="${1:-patch}"
|
||||
PLIST=Resources/Info.plist
|
||||
IME=windows/autozhuyin/ime.json
|
||||
|
||||
CURRENT="$(plutil -extract CFBundleShortVersionString raw "$PLIST")"
|
||||
IFS=. read -r MAJOR MINOR PATCH <<< "$CURRENT"
|
||||
case "$LEVEL" in
|
||||
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
|
||||
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
|
||||
patch) PATCH=$((PATCH + 1)) ;;
|
||||
*) echo "usage: $0 [patch|minor|major]" >&2; exit 2 ;;
|
||||
esac
|
||||
NEW="$MAJOR.$MINOR.$PATCH"
|
||||
BUILD=$(( $(plutil -extract CFBundleVersion raw "$PLIST") + 1 ))
|
||||
|
||||
plutil -replace CFBundleShortVersionString -string "$NEW" "$PLIST"
|
||||
plutil -replace CFBundleVersion -string "$BUILD" "$PLIST"
|
||||
# Edit only the version line so the rest of ime.json keeps its formatting.
|
||||
sed -i '' -E "s/(\"version\"[[:space:]]*:[[:space:]]*\")[^\"]*\"/\1$NEW\"/" "$IME"
|
||||
|
||||
grep -q "\"version\": \"$NEW\"" "$IME" || { echo "failed to update $IME" >&2; exit 1; }
|
||||
echo "$NEW"
|
||||
Executable
+54
@@ -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
|
||||
Reference in New Issue
Block a user