Spaces:
Running on Zero

File size: 1,347 Bytes
eef10ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-
"""Team-folder side: train the construction reader exactly as tools/mix_replies.py does (門檻 0.7, 解壓 省略關,
名字對齊開, 速率構式關) and pickle it with the 31-entry allow list (構式\\逐句混合_對齊_守門keep\\result.json) into
data/construction_reader.pkl, so the Space does not need the training data or the held-out guard.
    python -B tools/export_mix_reader.py"""
import json
import pickle
import sys
from pathlib import Path

sys.dont_write_bytecode = True
OUT = Path(__file__).resolve().parent.parent / "data" / "construction_reader.pkl"
sys.argv += ["--放行表=逐句混合_對齊_守門keep", "--守門=keep"]
sys.path.insert(0, str(Path(__file__).resolve().parent))
import mix_replies as MR  # noqa: E402

R, allow, trs = MR.build_reader()
K = MR.K
assert MR.G4.模式 == "keep" and MR.X.對齊開 and not K.開關.get("速率"), "settings differ from the measured ones"
meta = {"rules": len(R.rules), "allow": sorted(allow), "MIN_PREC": K.MIN_PREC, "省略開": MR.Z.省略開, "對齊開": MR.X.對齊開,
        "取代守門": MR.G4.模式, "速率": K.開關.get("速率"), "學習集題號": sorted(trs)}
OUT.write_bytes(pickle.dumps({"R": R, "meta": meta}))
print(OUT, OUT.stat().st_size, {k: v for k, v in meta.items() if k not in ("allow", "學習集題號")}, len(allow))