feat: separate contents, abstract and body evidence

This commit is contained in:
2026-10-01 00:07:40 +08:00
parent 540d0e2918
commit b7634c8374
25 changed files with 2592 additions and 172 deletions
+22
View File
@@ -176,6 +176,14 @@ class KnowledgePage(Base):
page = Column(Integer, primary_key=True)
text = Column(Text, nullable=False, default="")
image_path = Column(String(1200), nullable=True) # Relative to processed_path.
# Page-level classification: cover, abstract, toc, body, references or unknown.
page_type = Column(String(20), nullable=False, default="unknown", server_default="unknown")
mixed = Column(Boolean, nullable=False, default=False, server_default="false")
section = Column(String(500), default="")
chapter = Column(String(500), default="")
confidence = Column(Float, nullable=True)
# Bounded classifier evidence: which signals decided the type, kept for audit.
classification = Column(JSON, default=dict, nullable=False)
class KnowledgeChunk(Base):
@@ -187,6 +195,9 @@ class KnowledgeChunk(Base):
document_type = Column(String(80), nullable=False)
page = Column(Integer, nullable=False)
section = Column(String(500), default="")
chapter = Column(String(500), default="")
page_type = Column(String(20), nullable=False, default="unknown", server_default="unknown")
block_type = Column(String(20), nullable=False, default="body", server_default="body")
text = Column(Text, nullable=False)
embedding = Column(Embedding, nullable=True)
@@ -225,6 +236,9 @@ class CriterionScore(Base):
suggestion = Column(Text, default="")
status = Column(String(40), default="pending")
error = Column(Text, default="")
#: Content targets that still lacked body evidence, with the search that was run.
#: Kept after teacher review so the original retrieval problem stays auditable.
evidence_gaps = Column(JSON, default=list)
__table_args__ = (UniqueConstraint("batch_id", "project_id", "criterion_id"),)
@property
@@ -241,6 +255,14 @@ class ScoreEvidence(Base):
page = Column(Integer, nullable=False)
quote = Column(Text, nullable=False)
image_path = Column(String(1200), nullable=True)
# Which required-evidence target this quotation is offered to support.
target_id = Column(String(50), default="", server_default="")
target_label = Column(String(300), default="", server_default="")
# Page type of the source passage, and its role in the judgement.
page_type = Column(String(20), default="unknown", server_default="unknown")
source_role = Column(String(20), default="content", server_default="content")
# True when the quotation was written before this retrieval policy existed.
historical = Column(Boolean, default=False, nullable=False, server_default="false")
class TeacherRevision(Base):