Farm: Tor-9-All-in-Liste (Format fassung_tor.tor_allin), All-in-Zaehlung je Strasse, Call-Strich-Vergleich zweier Rauchproben

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Marc Mintel
2026-12-06 09:47:39 +01:00
co-authored by Claude Opus 5.5
parent 52ed00766d
commit 15cb1f5821
3 changed files with 83 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
"""Call-Striche zweier Rauchproben (Arm an): Zeilen mit Basiszug CALL und anderem Endzug, je Strasse und Art (letzte endpruefung-Art, Probe-Text).
callstrich.py <ein.jsonl> <name-vorher> <datei-vorher> <name-nachher> <datei-nachher>"""
import collections, json, re, sys
EIN, NA, FA, NB, FB = sys.argv[1:6]
ein = [json.loads(l) for l in open(EIN, encoding="utf-8")]
def strasse(i): e = ein[i]; return str(e.get("street") or e.get("strasse") or (e.get("state") or {}).get("street") or "?").upper()
def art(d):
ep = [p for p in (d.get("protokoll") or []) if p.get("wer") == "endpruefung"]
a = ep[-1].get("art") if ep else None
r = d.get("reason", ""); m = re.search(r"Range des Jammers: ([^,(]*)", r)
return f"{a or '-'} | {'Probe' if 'All-in-Probe Call' in r else 'ohne Probe'}{(' | ' + m.group(1).strip()) if m else ''}"
def striche(f):
r = {}
for i, l in enumerate(open(f, encoding="utf-8")):
d = json.loads(l); b = (d.get("basis") or {}).get("action")
if b == "CALL": r[i] = (d["action"] != "CALL", d["action"], art(d))
return r
a, b = striche(FA), striche(FB)
for n, s in ((NA, a), (NB, b)):
z = collections.Counter((strasse(i), x[2]) for i, x in s.items() if x[0])
print(f"CALL-STRICHE {n}: {sum(z.values())} von {len(s)} Basis-Calls", dict(sorted(((f'{k[0]} {k[1]}', v) for k, v in z.items()))))
for i in sorted(set(a) | set(b)):
x, y = a.get(i), b.get(i)
if (x and x[0]) != (y and y[0]) or (x and y and x[1] != y[1]):
print(f" Zeile {i} {strasse(i)}: {NA} {x[1] if x else 'kein Basis-Call'} [{x[2] if x else ''}] -> {NB} {y[1] if y else 'kein Basis-Call'} [{y[2] if y else ''}]")
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
"""All-in-Liste und Zaehlungen fuer exakt: je Anfrage, in der ein Arm all-in geht (allinBeleg vorhanden), beide Arme nebeneinander.
vk-allin.py <ordner> <teile> <ein.jsonl> <arm-a> <arm-b> -> <ordner>/allin-liste.json"""
import collections, json, os, sys
O, N, EIN, A, B = sys.argv[1], int(sys.argv[2]), sys.argv[3], sys.argv[4], sys.argv[5]
def antworten(arm):
r = {}
for t in range(N):
k = json.load(open(os.path.join(O, arm, f"teil{t}.jsonl.kopf.json")))
for i, z in zip(k["idx"], open(os.path.join(O, arm, f"teil{t}.jsonl"), encoding="utf-8")): r[i] = json.loads(z)
return r
ein = [json.loads(l) for l in open(EIN, encoding="utf-8")]
ra, rb = antworten(A), antworten(B)
def strasse(i, a, b):
for d in (a, b):
s = (d.get("allinBeleg") or {}).get("strasse")
if s: return s
e = ein[i]; return str(e.get("street") or e.get("strasse") or (e.get("state") or {}).get("street") or "?").upper()
def kurz(d): return {"action": d.get("action"), "size": d.get("size"), "quelle": d.get("quelle"), "allin": d.get("allinBeleg")}
zahl = collections.defaultdict(collections.Counter); liste = []; quelle = {A: collections.defaultdict(collections.Counter), B: collections.defaultdict(collections.Counter)}
for i in sorted(set(ra) & set(rb)):
a, b = ra[i], rb[i]; s = strasse(i, a, b)
for arm, d in ((A, a), (B, b)): quelle[arm][s][d.get("quelle") or "-"] += 1
ia, ib = "allinBeleg" in a, "allinBeleg" in b
if not (ia or ib): continue
gleich = (a.get("action"), a.get("size")) == (b.get("action"), b.get("size"))
zahl[s][f"allin_{A}"] += ia; zahl[s][f"allin_{B}"] += ib; zahl[s]["beide"] += ia and ib; zahl[s]["zug_anders"] += not gleich
zahl[s][f"nur_{A}"] += ia and not ib; zahl[s][f"nur_{B}"] += ib and not ia
liste.append({"idx": i, "strasse": s, "gleich": gleich, A: kurz(a), B: kurz(b)})
erg = {"arme": [A, B], "anfragen": len(set(ra) & set(rb)), "fehlend": {A: len(ein) - len(ra), B: len(ein) - len(rb)},
"allin_zaehlung": {s: dict(c) for s, c in zahl.items()}, "quelle_je_strasse": {arm: {s: dict(c) for s, c in q.items()} for arm, q in quelle.items()}, "liste": liste}
tmp = os.path.join(O, "allin-liste.json.tmp"); json.dump(erg, open(tmp, "w"), ensure_ascii=False, indent=1); os.replace(tmp, os.path.join(O, "allin-liste.json"))
print("ALLIN", json.dumps({k: erg[k] for k in ("anfragen", "fehlend", "allin_zaehlung")}, ensure_ascii=False))
print("QUELLE", json.dumps(erg["quelle_je_strasse"], ensure_ascii=False))
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
"""Tor-9-All-in-Liste (fassung_tor.tor_allin) aus den Kandidaten-Antworten: jede Antwort mit allinBeleg (eigenes All-in oder Call gegen All-in).
gelesen_von/urteil bleiben leer (liest main). tor9-liste.py <ordner> <teile> <arm> <idx-datei> <exe_sha256> -> <ordner>/tor9-allin-liste.json"""
import json, os, sys
O, N, ARM, IDX, SHA = sys.argv[1], int(sys.argv[2]), sys.argv[3], sys.argv[4], sys.argv[5]
orig = [l.split("\t") for l in open(IDX).read().splitlines()]
z = {}
for t in range(N):
k = json.load(open(os.path.join(O, ARM, f"teil{t}.jsonl.kopf.json")))
for i, l in zip(k["idx"], open(os.path.join(O, ARM, f"teil{t}.jsonl"), encoding="utf-8")): z[i] = json.loads(l)
allins = []
for i in sorted(z):
b = z[i].get("allinBeleg")
if not isinstance(b, dict): continue
e = {"id": int(orig[i][0]), "zeile_kurz": i, "gruppe": orig[i][1], "art": b.get("art"), "strasse": b.get("strasse"), "rechnungen": b.get("rechnungen"),
"zug": z[i].get("action"), "size": z[i].get("size"), "alternative": b.get("alternative"), "alternative_wert": b.get("alternative_wert")}
if "toleranz" in b: e["toleranz_bb"] = b["toleranz"]
if "toleranz_bb" in b: e["toleranz_bb"] = b["toleranz_bb"]
allins.append(e)
d = {"exe_sha256": SHA, "anfragen": len(z), "quelle": "ein-tor1 Teilmenge (04.12. ganz, 03.12. Turn/River und Vorflop ab Raise)", "allins": allins}
tmp = os.path.join(O, "tor9-allin-liste.json.tmp"); json.dump(d, open(tmp, "w"), ensure_ascii=False, indent=1); os.replace(tmp, os.path.join(O, "tor9-allin-liste.json"))
import collections
print("TOR9-LISTE", len(z), "Anfragen,", len(allins), "All-in/Call-gegen-All-in", dict(collections.Counter((a["strasse"], a["art"]) for a in allins)))