Download scratch/check_cycle.py from Lashtw/idle: direct link, hf CLI and curl.
- Browser
- Download file 953 Bytes
-
https://huggingface.co/spaces/Lashtw/idle/resolve/main/scratch/check_cycle.py
- Command line
-
hf download hf://spaces/Lashtw/idle/scratch/check_cycle.py
-
curl -L -o check_cycle.py https://huggingface.co/spaces/Lashtw/idle/resolve/main/scratch/check_cycle.py
953 Bytes
| import json | |
| import os | |
| import sys | |
| sys.stdout.reconfigure(encoding='utf-8') | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| def check_round_pages(part): | |
| folder = os.path.join(ROOT, 'scratch', 'ocr', part) | |
| pages = [] | |
| for p in range(1, 105): | |
| path = os.path.join(folder, f'p{p:03d}.json') | |
| if not os.path.exists(path): | |
| continue | |
| with open(path, 'r', encoding='utf-8') as f: | |
| items = json.load(f) | |
| texts = [it['text'] for it in items] | |
| full_text = " ".join(texts) | |
| has_round = False | |
| nums = [] | |
| for it in items: | |
| t = it['text'].strip() | |
| if len(t) == 3 and t.isdigit(): | |
| nums.append(int(t)) | |
| pages.append((p, nums, texts[:2])) | |
| print(f"--- Part {part} Summary ---") | |
| for p, nums, top in pages: | |
| if nums: | |
| print(f"p{p:03d}: nums={nums} | top={top}") | |
| check_round_pages('A') | |