local-label-queue / make_sample.py
WideChaos's picture
Publish Local Label Queue 0.1.0
d806877 verified
Raw History Blame Contribute Delete
1.27 kB
"""Freeze a small authored inventory before annotation-queue implementation."""
import hashlib,json
from pathlib import Path
r=Path(__file__).resolve().parent
if (r/'sample.jsonl').exists():raise SystemExit('Sample already frozen; not overwritten.')
texts=['The page stays blank after I click Save.','Where can I find the export button?','Here is a small example input.','The same record appears twice in the list.','Can a group be left unknown?','This sample uses a template family.','保存后页面仍然是空白。','怎样导出当前标注?','这是一个最小输入示例。','A literal <script> is text, not a command.','The note contains emoji 😀 and Café.','One record may remain undecided.']
rows=[{'id':f'item-{i+1:02d}','group':('family-'+str(i//3+1) if i<9 else None),'text':text}for i,text in enumerate(texts)]
(r/'sample.jsonl').write_text(''.join(json.dumps(x,ensure_ascii=False)+'\n'for x in rows))
(r/'SAMPLE-SNAPSHOT.json').write_text(json.dumps({'phase':'before implementation','origin':'12 authored synthetic items, no gold annotation labels','unknown_group_items':3,'sha256':hashlib.sha256((r/'sample.jsonl').read_bytes()).hexdigest()},indent=2)+'\n')
print('Frozen12-iteminventory',hashlib.sha256((r/'sample.jsonl').read_bytes()).hexdigest())