feat: 决策240/241——子级工料机二次合并视野与换码贯通、AdminCost 封存及台账更新
This commit is contained in:
33
AdminCost/参考资料/规范与COS4/scripts/ocr_all.py
Normal file
33
AdminCost/参考资料/规范与COS4/scripts/ocr_all.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""批量 OCR:PDF 52-146(第6章),逐页增量落盘,可断点续跑"""
|
||||
import os, json, sys, time
|
||||
sys.path.insert(0, r"C:\Users\MZ\AppData\Local\Temp\cos4std")
|
||||
from ocr_page import ocr_page, BASE
|
||||
|
||||
OUT = os.path.join(BASE, "ocr_ch6.json")
|
||||
START, END = 52, 146
|
||||
|
||||
data = {}
|
||||
if os.path.exists(OUT):
|
||||
try:
|
||||
data = json.load(open(OUT, encoding="utf-8"))
|
||||
print("resume, have", len(data))
|
||||
except Exception:
|
||||
data = {}
|
||||
|
||||
t0 = time.time()
|
||||
for n in range(START, END + 1):
|
||||
key = "p%03d" % n
|
||||
if key in data and data[key]:
|
||||
continue
|
||||
try:
|
||||
data[key] = ocr_page(n)
|
||||
print("%s ok items=%d %.0fs" % (key, len(data[key]), time.time() - t0), flush=True)
|
||||
except Exception as e:
|
||||
print("%s FAIL %s" % (key, e), flush=True)
|
||||
data[key] = []
|
||||
if n % 5 == 0:
|
||||
json.dump(data, open(OUT, "w", encoding="utf-8"), ensure_ascii=False)
|
||||
|
||||
json.dump(data, open(OUT, "w", encoding="utf-8"), ensure_ascii=False)
|
||||
print("done", len(data), "%.0fs" % (time.time() - t0))
|
||||
Reference in New Issue
Block a user