Cotton code
29 lines · 1.9 KB · ShellRaw
#!/usr/bin/env bash# Replay an ink corpus through the recogniser on this Mac, in seconds.##   pnpm ink:corpus <folder>                  # <folder> holds the phone's *.jsonl and labels.json#   pnpm ink:corpus <folder> --floors 0,0.1   # the curve letter_confidence is chosen on#   pnpm ink:corpus <folder> --band           # the model's best scores, right, wrong and noise#   pnpm ink:corpus --lag                     # each letter's wait, synthetic walk and the 24 traces## The reading is the core's (`cotton_core::ink`, replayed by# `crates/cotton-core/examples/ink_corpus.rs`): the same rules every phone# runs. The letter model is Core ML, which the Mac runs as the phone does, so# the example asks it through a child built here with swiftc from the app's# own `InkModel.swift` (`corpus-harness/main.swift`) — no simulator, no app# build. Synthetic or labelled corpora only; nothing is read from a phone here.set -euo pipefailROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"INK="$ROOT/apps/cotton/Sources/CottonUI/Ink"OUT="${TMPDIR:-/tmp}/ink-corpus-$(id -u)"mkdir -p "$OUT"swiftc -O -module-name InkModelCLI -o "$OUT/ink-model" \  "$INK/InkModel.swift" "$ROOT/scripts/ink/corpus-harness/resources.swift" "$ROOT/scripts/ink/corpus-harness/main.swift"# From the root, so the checkout's cargo config (its shared target) applies;# under the machine's build lock like every compile here.cd "$ROOT"BUILD_LOCK_LABEL=ink-corpus bash "$ROOT/scripts/with-build-lock.sh" \  cargo build -q --release -p cotton-core --example ink_corpus --manifest-path "$ROOT/crates/Cargo.toml"TARGET="$(cargo metadata -q --format-version 1 --no-deps --manifest-path "$ROOT/crates/Cargo.toml" | python3 -c 'import json, sys; print(json.load(sys.stdin)["target_directory"])')"INK_MODEL_CLI="$OUT/ink-model" INK_FIXTURES="$ROOT/crates/cotton-core/tests/fixtures/ink" \  COTTON_UI_RESOURCES="$ROOT/apps/cotton/Sources/CottonUI/Resources" "$TARGET/release/examples/ink_corpus" "$@"