# -*- coding: utf-8 -*- """ OCR 附件检测测试入口。 实际逻辑已迁移至 app/utils/ocr.py,本文件仅做导入与自测。 """ import os import sys # 项目根目录 = tests 的上级目录,保证可导入 app 包 _PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if _PROJECT_ROOT not in sys.path: sys.path.insert(0, _PROJECT_ROOT) from app.utils.ocr import check_leave_attachment, marriage_within_one_year, extract_dates if __name__ == "__main__": # 替换为你的附件路径,修改 leave_type 即可测试不同假期 test_path = r"D:\downloads\ocr_test_01.png" print("病假检测(开启调试)") result = check_leave_attachment(test_path, leave_type="sick", debug=True) print(f"病假检测结果:{result}\n") # 测试婚假检测 + 登记日期 1 年内 # result = check_leave_attachment("结婚证图片路径", leave_type="marriage", debug=True) # print(f"婚假检测结果:{result}") # ok, reg_date = marriage_within_one_year("结婚证图片路径", debug=True) # print(f"登记日期:{reg_date},1年内:{ok}") # 测试产检假检测 # result = check_leave_attachment("产检单图片路径", leave_type="maternity", debug=True) # print(f"产检假检测结果:{result}") # 日期提取单测 print("日期提取测试:", extract_dates("2025年5月20日登记,出生1998年3月2日,2025-05-20"))