feat: OCR 新增支持西班牙/意大利/加拿大(ES/IT/CA) #6

Merged
inkreach merged 2 commits from inkreach/ocr-es-it-ca AGit into main 2026-09-24 03:56:05 +00:00
3 changed files with 10 additions and 5 deletions
+4 -1
View File
@@ -12,7 +12,10 @@ jobs:
- name: 检出代码
run: |
REF="${{ github.event.pull_request.head.ref || github.ref_name }}"
git clone --depth 1 --branch "$REF" "${{ github.server_url }}/${{ github.repository }}.git" .
git clone --depth 1 "${{ github.server_url }}/${{ github.repository }}.git" .
# PR head 可能是完整 ref(AGit 建的 PR 为 refs/pull/N/head),clone --branch 只认分支名,改 fetch 后 checkout
git fetch --depth 1 origin "$REF"
git checkout --detach FETCH_HEAD
- name: 安装 uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: 安装依赖
+3 -1
View File
@@ -37,14 +37,16 @@ class OcrResult(BaseModel):
# OCR 服务已有分类器模型的国家(版面见 api.md §4)
SUPPORTED_COUNTRIES = {"US", "UK", "DE", "MX", "SA"}
SUPPORTED_COUNTRIES = {"US", "UK", "DE", "MX", "SA", "CA", "ES", "IT"}
# ISO 国家代码 / 中文国名 → OCR 国家代码
_COUNTRY_MAP: dict[str, str] = {
# 代码
"GB": "UK", "UK": "UK", "US": "US", "DE": "DE", "MX": "MX", "SA": "SA",
"CA": "CA", "ES": "ES", "IT": "IT",
# 中文名
"英国": "UK", "美国": "US", "德国": "DE", "墨西哥": "MX", "沙特": "SA",
"加拿大": "CA", "西班牙": "ES", "意大利": "IT",
}
+3 -3
View File
@@ -137,12 +137,12 @@ def label_ocr(
courier_source: str | None = None,
days: int = 7,
) -> dict:
"""面单 OCR enrichment。默认处理英国+美国,近 7 天下单的订单。
"""面单 OCR enrichment。默认处理全部已支持国家(见 api.ocr.models.SUPPORTED_COUNTRIES),近 7 天下单的订单。
手动跑其他国家: label_ocr(country_regions=['德国'])
手动跑指定国家: label_ocr(country_regions=['德国'])
"""
if country_regions is None:
country_regions = ['英国', '美国', '墨西哥', '德国', '沙特']
country_regions = ['英国', '美国', '墨西哥', '德国', '沙特', '加拿大', '西班牙', '意大利']
if _has_running_peer():
print("已有 label-ocr 在运行,跳过本次")
return {"skipped": True}