Design it step by step
Keep an immutable source snapshot
Store line IDs, original characters, and blank-line metadata for an invented notice. Record whitespace normalization. Formatting restoration must not silently invent dates, prices, or sentences.
Parse explicit markers first
Handle headings, list markers, and code fences with deterministic parsing. Preserve command and table boundaries; a number in a sentence is not automatically a list item.
Judge only unclear line relationships
Ask whether an adjacent line continues an interrupted sentence, not merely whether the lines are related. Two registration lines may be different clauses. Separate semantic decisions from text joining.
Classify blocks after they exist
Choice can label formed blocks as headings, prose, lists, or code. This stage depends on previous joins. Code adds Markdown markers and keeps block-to-line provenance for reversal.
Check integrity and display separately
Compare numbers, dates, links, and commands with the source, then inspect headings and mobile layout. Escape HTML and prevent source scripts from executing. Invented “120” remains source text, not a generated replacement.
Worked example · Invented by this site
| Observation | Judgment | Application action |
|---|---|---|
| “Please register” plus “by Friday” | Possible sentence continuation | Join with source IDs |
| “Fee 120” plus “Non-refundable” | Related, possibly separate clauses | Preserve or review the boundary |
| Source contains HTML | Content is not executable authority | Escape before display |
A copyable design draft
Original examples. JSON illustrates request or input structure; Python calculates invented scores without an API call. Verify current interfaces and task policy before integrating.
# Offline provenance and safe-display example.
from html import escape
lines = {"L1": "Workshop notice", "L2": "Register by Friday."}
block = {"id": "B1", "source_ids": ["L2"], "kind": "paragraph"}
text = " ".join(lines[line_id] for line_id in block["source_ids"])
print(escape(text)) # Register by Friday.
# Joining and classification judgments are not performed here.Design a decisionCommon mistakes
- Joining based on topical similarity.
- Replacing source text with generated prose.
- Executing HTML from restored documents.
TRY / THINK / COMPARE
Think first, then compare
Two lines concern the event, but one is a refund clause. Join automatically?
Show explanation
No. Test sentence continuation and retain clause boundaries; preserve uncertain text for review.
Before handing it over
- Source snapshots and line IDs retained.
- Joining, block labeling, and rendering separated.
- Numbers and links compared.
- Rendered content escaped.
Common questions
Can you guarantee identical characters?
Define whitespace handling and validate content; this page is not a live model test.
Should OCR corrections be included?
Treat correction as a separate task with its own review.
Sources and further reading
Inspired by official patterns and Datawhale practice topics. Explanations, examples, and exercises are independently written. These are teaching designs, not live API runs or benchmarks.