项目文件夹

文件
wehub-resource-sync 925e56bb5f
Unit tests / build (t4_gpu) (push) Has been cancelled
Unit tests / build (ubuntu-latest) (push) Has been cancelled
Unit tests / build (windows-latest) (push) Has been cancelled
Test CLI scripts / build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:24:56 +08:00

49 行
1.1 KiB
Python

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
from typing import List, Optional
from pydantic import BaseModel
from surya.common.polygon import PolygonBox
class TableRow(PolygonBox):
row_id: int
@property
def label(self) -> str:
return f"Row {self.row_id}"
class TableCol(PolygonBox):
col_id: int
@property
def label(self) -> str:
return f"Column {self.col_id}"
class TableCell(PolygonBox):
"""Geometric cell derived from row × column intersection.
The simple-path TableRecPredictor doesn't return spanning info from the
model — colspan/rowspan/header come from the full-path HTML output if
needed."""
row_id: int
col_id: int
cell_id: int
@property
def label(self) -> str:
return f"Cell {self.cell_id}"
class TableResult(BaseModel):
rows: List[TableRow]
cols: List[TableCol]
cells: List[TableCell]
image_bbox: List[float]
raw: Optional[str] = None # raw model output
html: Optional[str] = None # populated when full-path was used
mode: str = "simple" # "simple" | "full"
error: bool = False