package local.hex.bench; import ly.anoma.hex.typing.*; import org.json.*; import java.io.*; import java.util.*; /** Runs via app_process against the actual installed APK. Never built into Hex. */ public final class Replay { static KeyGrid originalGeometry(String language) { // Portrait KeyboardLayout at 402 pt (side 6.5, gap 6, letter height 45, row gap 11). double pitch = 39.5; Map points = new LinkedHashMap<>(); String[] rows = {"qwertyuiop", language.equals("es") ? "asdfghjklñ" : "asdfghjkl", "zxcvbnm"}; for (int row=0; row w.replaceAll("[.,!?;:]+$", "")).filter(w -> !w.isEmpty()).toArray(String[]::new); } static int edits(String[] ref, String[] hyp) { int[] d = new int[hyp.length+1]; for(int j=0;j ns) { Collections.sort(ns); System.out.printf(Locale.ROOT,"latency\t%s\t%d\t%.4f\t%.4f\t%.4f\n", name,ns.size(),ns.get(ns.size()/2)/1e6,ns.get(ns.size()*95/100)/1e6,ns.get(ns.size()-1)/1e6); } public static void main(String[] args) throws Exception { String lang=args[2], group=lang.equals("es") ? "es-test-" : "test-"; TypingModel model=TypingModel.Companion.file(new File(args[0]),lang); KeyGrid grid=originalGeometry(lang); TypingWord state=new TypingWord(new SpatialDecoder(model), true); List letters=new ArrayList<>(), spaces=new ArrayList<>(); int count=0, total=0, matches=0; int[] errors=new int[3], exact=new int[3]; try (BufferedReader reader=new BufferedReader(new FileReader(args[1]))) { String line; while((line=reader.readLine())!=null) { JSONObject r=new JSONObject(line); if(!r.getString("id").equals(group+count)) throw new IllegalArgumentException("Unexpected row "+count); String typed=r.getString("typed"); JSONArray taps=r.getJSONArray("taps"); if(typed.length()!=taps.length()) throw new IllegalArgumentException("Unaligned taps"); StringBuilder out=new StringBuilder(); state.reset(""); for(int i=0;i