agentleFS
scholayscholay/skills/corpus-building/SKILL.md

corpus-building

Skill141 starsChanged 5 months agoMITView on GitHub

Extract, structure, and quality-check evidence from registered source objects. Use when converting processed documents into searchable evidence cards, managing OCR and translation layers, running quality scoring, handling noise and recovery, or maintaining a corpus index.

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 13 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before creating any slices, create a source card for the registered source object.

    line 28
  2. Distinctive:

    Default path: use a local OCR engine (Tesseract or equivalent).

    line 34
  3. Very specific:

    On image descriptions: use a multimodal model to inspect the actual image pixels.

    line 57
  4. Distinctive:

    After slicing, score each page on:

    line 61
  5. Distinctive:

    Calibrate before scaling: after your first new source type, inspect all P1 pages plus a sample of P2 and OK.

    line 71
  6. Distinctive:

    Before bulk quarantine, sample the flagged pages visually.

    line 80
  7. Distinctive:

    After every batch, validate that:

    line 88
  8. Distinctive:

    Every slice card in your folder has a row in your index

    line 89
  9. Distinctive:

    No duplicate slice IDs exist

    line 90
  10. Distinctive:

    No index rows reference missing files

    line 91
  11. Distinctive:

    Never let a translation overwrite the original text or the OCR-cleaned text.

    line 98
  12. Distinctive:

    Never use OCR output as a substitute for visual inspection of images.

    line 99
  13. Distinctive:

    Do not create slices from unregistered source objects.

    line 100
  14. Distinctive:

    Do not run quality scoring and then ignore the results — calibrate the scorer and act on P1 pages.

    line 101
  15. Very specific:

    Read references/slice-schema.md for required fields, status vocabulary, and granularity rules.

    line 118
  16. Very specific:

    Read references/quality-scoring.md for triage priority semantics, risk tags, and calibration guidance.

    line 119
  17. Very specific:

    Read references/ocr-noise.md for common noise patterns, false-positive quarantine risks, and recovery steps.

    line 120

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Corpus Building

The core problem

A folder of PDFs is not a corpus. A corpus is a collection of addressable evidence units — each one traceable to a specific page of a specific source, with enough context to be used in writing without reopening the original document.

This skill covers the full path from source object to evidence card, including OCR, translation, quality scoring, and the noise problems that appear at scale.

Key concepts

Source card — one record per registered source. Holds metadata, processing status, and links to all derived evidence.

Text slice — one evidence unit extracted from a specific page range of a source. Stores the original text, cleaned OCR text, and working translation as separate layers. Never collapses them.

Image slice — one image evidence unit (a page scan, figure, plan, photograph, table, or diagram). Stores file path, description, and status.

The separation rule: a slice stores what the source says. AI annotations store what AI thinks about the slice. Do not mix them.

Workflow

1. Create the source card first

Before creating any slices, create a source card for the registered source object. Minimum fields: source ID, title, language, file path, topics, status fields for OCR and translation.

2. Run OCR

For each source, generate per-page text output.

Default path: use a local OCR engine (Tesseract or equivalent). For multilingual documents, set the language pack explicitly — running an incorrect language pack produces script-mismatch noise, not just bad quality.

Cloud OCR path (optional): use a cloud OCR API for higher fidelity on difficult scans. Reserve this for pages that local OCR consistently fails on, not as a default for all sources.

Output per page: raw OCR text file. Keep raw output separate from any cleaned version.

3. Slice into evidence cards

For each page (or logical text unit), create a text slice card with:

  • Slice ID (SLC-####-T###)
  • Source ID and page reference
  • Original text (from source)
  • OCR-cleaned text (if different)
  • Working translation (in your project's working language)
  • Status fields: OCR status, translation status, verification status

For each page image, create a baseline image slice card with:

  • Slice ID (SLC-####-I###)
  • Source ID and page number
  • Image file path
  • Image type (page scan, figure, plan, photo, table, diagram)
  • Description status

On image descriptions: use a multimodal model to inspect the actual image pixels. Do not use OCR output as a substitute for visual inspection. Label OCR-derived descriptions as ocr_assisted_draft — they are lower trust than a genuine visual description.

4. Run quality scoring

After slicing, score each page on:

  • OCR quality: are there repeated characters, symbol noise, script artifacts?
  • Translation quality: is the working language layer present and readable?

Assign a triage priority:

  • P1 — likely broken; inspect immediately before using
  • P2 — needs review; often image-heavy or missing translation
  • P3 — usable but worth spot-checking
  • OK — acceptable for browsing

Calibrate before scaling: after your first new source type, inspect all P1 pages plus a sample of P2 and OK. If the scoring looks wrong, fix the scorer before running 50 more sources.

5. Handle noise and blocked pages

At scale, some pages will have OCR artifacts severe enough to quarantine:

  • Repeated-character runs
  • Script mismatch (wrong language pack)
  • Symbol floods

Before bulk quarantine, sample the flagged pages visually. Common false positives:

  • Table-of-contents pages with dotted leaders (…………) — readable, just unusual
  • Pages in a different script than you expected — fix the language setting, not the page

For genuinely noisy pages, mark them excluded and log them in a blocked pages list with a reason code. Revisit after fixing the underlying cause (wrong language pack, poor scan quality, etc.) rather than leaving them permanently blocked.

6. Validate and rebuild

After every batch, validate that:

  • Every slice card in your folder has a row in your index
  • No duplicate slice IDs exist
  • No index rows reference missing files

Rebuild any downstream views (app data, search indexes) from the validated corpus, not from cached state.

Rules

  • Markdown/text cards are the source of truth. CSV/database indexes are rebuildable projections.
  • Never let a translation overwrite the original text or the OCR-cleaned text. Keep all three layers.
  • Never use OCR output as a substitute for visual inspection of images.
  • Do not create slices from unregistered source objects.
  • Do not run quality scoring and then ignore the results — calibrate the scorer and act on P1 pages.
  • Over-quarantine is as harmful as under-quarantine. Sample before bulk-blocking.
  • Auto-generated page slices are browsing inventory, not citation-ready evidence. Mark them accordingly.
  • Validate after every batch. Do not continue slicing when validation fails.

Status vocabulary

OCR status: not_started / in_progress / raw_ocr / cleaned / verified / blocked / not_needed

Translation status: not_started / machine_draft / agent_draft / pending_translation / reviewed / quote_ready / blocked / not_needed

Verification status: draft / checked / reviewed

Image description status: not_started / ocr_assisted_draft / visual_draft / reviewed / caption_ready

References

  • Read references/slice-schema.md for required fields, status vocabulary, and granularity rules.
  • Read references/quality-scoring.md for triage priority semantics, risk tags, and calibration guidance.
  • Read references/ocr-noise.md for common noise patterns, false-positive quarantine risks, and recovery steps.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.