feat:LLM 分析文件并生成结构化建议
This commit is contained in:
@@ -8,8 +8,8 @@ import re
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
from app.datafiles.base import MAX_TABLE_ROWS, rows_exceeded, where
|
||||
from app.datafiles.columns import classify, label_text
|
||||
from app.datafiles.base import MAX_TABLE_ROWS, brief, rows_exceeded, where
|
||||
from app.datafiles.columns import as_text, classify
|
||||
from app.datafiles.readers import Grid
|
||||
from app.schemas.data_file import ParseWarning
|
||||
|
||||
@@ -209,9 +209,7 @@ def _finish(rows: list[list[Any]], piece: _Piece, sheet: str | None) -> RawTable
|
||||
totals = [index for index, row in data if _is_total(row)]
|
||||
if totals:
|
||||
data = [(index, row) for index, row in data if not _is_total(row)]
|
||||
listed = "、".join(str(index + 1) for index in totals[:5]) + (
|
||||
"等" if len(totals) > 5 else ""
|
||||
)
|
||||
listed = brief([str(index + 1) for index in totals])
|
||||
warnings.append(
|
||||
ParseWarning(
|
||||
code="total_rows_removed",
|
||||
@@ -250,7 +248,7 @@ def _merge_header(top: list[Any], sub: list[Any]) -> list[str]:
|
||||
for upper, lower in zip(top, sub):
|
||||
if upper is not None:
|
||||
carry = upper
|
||||
parts = [label_text(part) for part in (carry, lower) if part is not None]
|
||||
parts = [as_text(part) for part in (carry, lower) if part is not None]
|
||||
merged.append("-".join(parts))
|
||||
return merged
|
||||
|
||||
@@ -280,7 +278,7 @@ def _quote(row: list[Any]) -> str:
|
||||
value = next((value for value in row if value is not None), None)
|
||||
if value is None:
|
||||
return ""
|
||||
text = label_text(value)
|
||||
text = as_text(value)
|
||||
if len(text) > QUOTE_CHARS:
|
||||
text = text[:QUOTE_CHARS] + "…"
|
||||
return f"「{text}」"
|
||||
|
||||
Reference in New Issue
Block a user