verify_batches.py 逐批比對 id;make_relabel.py 挑出需重標的 none; merge_labels.py 支援多個目錄覆蓋與 confidence 縮寫;worry 加入情緒白名單。 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""逐批檢查標註輸出和輸入的 id 完全一致、順序相同,並列出缺漏與錯置。
|
|
|
|
用法:verify_batches.py <批次目錄,內含 in/ 與 out/>
|
|
多個 agent 並行寫檔時可能互相覆蓋或寫錯批次,只看格式抓不到,所以要比對 id。
|
|
"""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def ids(path):
|
|
return [json.loads(line)["id"] for line in Path(path).read_text(encoding="utf-8").splitlines() if line.strip()]
|
|
|
|
|
|
def main():
|
|
root = Path(sys.argv[1])
|
|
bad, missing = [], []
|
|
for src in sorted((root / "in").glob("batch-*.jsonl")):
|
|
out = root / "out" / src.name
|
|
if not out.exists():
|
|
missing.append(src.name)
|
|
continue
|
|
a, b = ids(src), ids(out)
|
|
if a != b:
|
|
bad.append((src.name, len(a), len(b), sorted(set(a) ^ set(b))[:3]))
|
|
print(f"缺 {len(missing)} 批:{missing}")
|
|
print(f"id 不一致 {len(bad)} 批:")
|
|
for row in bad:
|
|
print(" ", row)
|
|
sys.exit(1 if bad or missing else 0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|