feat(govdoc): 补 structure/outline API 端点
This commit is contained in:
@@ -86,6 +86,37 @@ class ResultAdapter:
|
||||
})
|
||||
return entities
|
||||
|
||||
def AdaptStructure(self, EngineResult: AuditResult) -> list[dict[str, Any]]:
|
||||
"""从 AuditResult.structure 提取文档结构统计。"""
|
||||
results: list[dict[str, Any]] = []
|
||||
for s in EngineResult.structure:
|
||||
results.append({
|
||||
"role": s.role,
|
||||
"label": s.label,
|
||||
"count": s.count,
|
||||
"expected": s.expected,
|
||||
"paragraphIndices": s.paragraph_indices,
|
||||
"samples": s.samples,
|
||||
"charTotal": s.char_total,
|
||||
"dominantFont": s.dominant_font,
|
||||
"dominantSizePt": s.dominant_size_pt,
|
||||
"styleUniform": s.style_uniform,
|
||||
})
|
||||
return results
|
||||
|
||||
def AdaptOutline(self, EngineResult: AuditResult) -> list[dict[str, Any]]:
|
||||
"""从 AuditResult.outline 提取大纲树(递归)。"""
|
||||
|
||||
def _node(n) -> dict[str, Any]:
|
||||
return {
|
||||
"paragraphIndex": n.paragraph_index,
|
||||
"level": n.level,
|
||||
"text": n.text,
|
||||
"children": [_node(c) for c in (n.children or [])],
|
||||
}
|
||||
|
||||
return [_node(n) for n in EngineResult.outline]
|
||||
|
||||
def AdaptArtifacts(self, _EngineResult: AuditResult, _RunId: int) -> list[dict[str, Any]]:
|
||||
"""从引擎结果提取报告产物清单。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user