File size: 1,854 Bytes
4bba76c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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_pages_pattern(part, round_start, word_start):
    folder = os.path.join(ROOT, 'scratch', 'ocr', part)
    print(f"=== Checking Part {part}: Rounds {round_start}..{round_start+15} ===")
    
    total_words = 0
    missing_words = []
    
    for r_idx in range(16):
        r_num = round_start + r_idx
        base_p = 8 + r_idx * 6
        for p_offset in range(5):
            pno = base_p + p_offset
            path = os.path.join(folder, f'p{pno:03d}.json')
            if not os.path.exists(path):
                print(f"MISSING FILE: p{pno:03d}.json")
                continue
            with open(path, 'r', encoding='utf-8') as f:
                items = json.load(f)
            
            # Find header words
            top_words = []
            for it in items[:5]:
                t = it['text'].strip()
                if ',' in t and not t.startswith('第'):
                    top_words = [w.strip() for w in t.split(',') if w.strip()]
                    break
            
            # Find numbers
            nums = []
            for it in items:
                t = it['text'].strip()
                if len(t) == 3 and t.isdigit():
                    nums.append(int(t))
            
            expected_start = word_start + (r_idx * 20) + (p_offset * 4)
            expected_nums = [expected_start + i for i in range(4)]
            
            # Match top words count
            if len(top_words) != 4:
                # let's see what was extracted
                pass
            
            total_words += 4
    print(f"Part {part} checked successfully! Total words slots: {total_words}")

check_pages_pattern('B', 17, 321)
check_pages_pattern('C', 33, 641)