interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / docs / native / pi5-8 / orchestrator-exam / reflex_tables.sh

45 lines · 2438 bytes Raw Blame History
1#!/bin/bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Tables for ALLEN REFLEX (docs/native/PI5-8-ALLEN-REFLEX.md). Reads only results/allen-reflex.<split>.<mode>.jsonl.
18# usage: reflex_tables.sh <split> [<split> ...] e.g. reflex_tables.sh train dev
19# 1. score.sh rows (unchanged scorer), 2. per category: action ok / exact ok / n, 3. per expected label: action ok / exact ok / n, 4. macro exact (mean over expected labels present).
20here=$(cd "$(dirname "$0")" && pwd)
21modes="reflex nearest perceptron"
22"$here/score.sh" --header
23for s in "$@"; do for m in $modes; do "$here/score.sh" allen-reflex "$s" "$m"; done; done
24norm='def norm: ascii_downcase | gsub("\\s+";" ") | sub("[.!?;,\\s]+$";"") | sub("^\\s+";"") | sub("\\s+$";"");'
25for key in cat exp_action; do
26 printf '\nper %s: action_ok/exact_ok/n\n' "$key"
27 for s in "$@"; do
28 for m in $modes; do
29 jq -r "$norm"' (.raw|fromjson) as $o
30 | [.'"$key"', (if $o.action==.exp_action then 1 else 0 end),
31 (if $o.action==.exp_action and ((.exp_text=="") or (($o.args.text // "")|norm)==(.exp_text|norm)) then 1 else 0 end)] | @tsv' \
32 "$here/results/allen-reflex.$s.$m.jsonl" |
33 awk -F'\t' -v s="$s" -v m="$m" '{a[$1]+=$2; e[$1]+=$3; n[$1]++} END{for(k in n) printf "%s\t%s\t%s\t%d/%d/%d\n", s, m, k, a[k], e[k], n[k]}' | sort -k3,3
34 done
35 done
36done
37printf '\nmacro exact over expected labels\n'
38for s in "$@"; do
39 for m in $modes; do
40 jq -r "$norm"' (.raw|fromjson) as $o
41 | [.exp_action, (if $o.action==.exp_action and ((.exp_text=="") or (($o.args.text // "")|norm)==(.exp_text|norm)) then 1 else 0 end)] | @tsv' \
42 "$here/results/allen-reflex.$s.$m.jsonl" |
43 awk -F'\t' -v s="$s" -v m="$m" '{e[$1]+=$2; n[$1]++} END{t=0; k=0; for(x in n){t+=e[x]/n[x]; k++} printf "%s\t%s\t%.1f%% over %d labels\n", s, m, 100*t/k, k}'
44 done
45done