Skip to main content

Dorsal

PyPI version codecov License

Dorsal Adapters translates schema-validated JSON records into a number of standard file formats.

Supported Formats

Document Extraction (open/document-extraction)

  • md: RAG-Optimized Markdown — Injects semantic headings into the text for LLM consumption.
  • html: Semantic HTML (.html) — Renders a responsive, visually inferred 2D DOM layout from raw spatial coordinates.
  • hocr: hOCR (.hocr.html) — An industry-standard OCR output format embedding layout, confidence scores, and style information in standard HTML.
  • tsv: Tab-Separated Values — Perfect for spreadsheet ingestion and tabular data analysis.
  • txt: Plain Text — Flattens the document layout into clean, stitched paragraphs.

Audio Transcription (open/audio-transcription)

  • srt: SubRip Text (.srt) — The most widely used plaintext subtitle format.
  • vtt: WebVTT (.vtt) — The W3C standard web subtitle format for HTML5 video players.
  • md: RAG-Optimized Markdown — Merges speaker tags, non-verbal events (e.g., [laughter]), and low-confidence warnings into clean markdown.
  • tsv: Tab-Separated Values — Organizes segments, start/end times, and speakers into a neat table.
  • txt: Plain Text — A continuous, readable transcript.

arXiv Metadata (dorsal/arxiv)

  • bib: BibTeX (.bib) — Standard bibliographic reference format.
  • csl-json: CSL-JSON (.json) — Standard bibliographic reference format.
  • ris: RIS (.ris) — Standard bibliographic reference format.
  • md: RAG-Optimized Markdown — YAML frontmatter (ID, DOI, Categories, Year) and markdown formatting for ingestion into PKMs or RAG pipelines.

Installation

Dorsal Adapters is available on PyPI as dorsalhub-adapters:

pip install dorsalhub-adapters

Usage

Within Dorsal

Dorsal Adapters is a core dependency for Dorsal.

Example: using --export to generate a subtitle file:

$ dorsal run dorsalhub/whisper /home/video/test.mkv --export=srt
1
00:00:01,970 --> 00:00:05,970
You might be wondering how I ended up in this situation.

2
00:00:05,970 --> 00:00:08,970
Yeah that's me. A young subtitle.

3
00:00:08,970 --> 00:00:18,590
Little did I know what life had in store for me.


Outputs saved successfully:
  ↳ /home/user/sandbox/test.dorsal.json
  ↳ /home/user/sandbox/test.srt
  • --export can take the ID of adapter for a given output schema (e.g. md for Markdown or txt for text).

Example 2: using --export to generate a BibTeX citation from an ArXiv preprint:

$ dorsal run dorsalhub/arxiv-pdf ./examples/9304001v1.pdf --export=bibtex
@misc{solv-int_9304001,
  title = {q-Discrete Toda Molecule Equation},
  author = {Kenji Kajiwara and Yasuhiro Ohta and Junkichi Satsuma},
  eprint = {solv-int/9304001},
  archivePrefix = {arXiv},
  primaryClass = {solv-int},
  doi = {10.1016/0375-9601(93)90705-5},
  url = {https://arxiv.org/abs/solv-int/9304001},
  year = {1993}
}
Outputs saved successfully:
  ↳ /home/user/sandbox/arxiv-pdf/9304001v1.dorsal.json
  ↳ /home/user/sandbox/arxiv-pdf/9304001v1.bib

Standalone Usage

Adapters are Python classes with methods for exporting to and parsing from the supported file formats:

  • export(record) / export_file(record, fp): Converts a JSON record into a standard format.
  • parse(content) / parse_file(fp): Best-effort conversion from a standard format back into a Dorsal JSON Record.

Example: Audio to Subtitles (SRT)

In this example, a valid open/audio-transcription record is converted into a subtitle file.

from dorsal_adapters.registry import get_adapter

# 1. The raw JSON record from your model
transcription = {
    "track_id": 1,
    "language": "eng",
    "segments": [
        {
            "start_time": 0.5,
            "end_time": 4.75,
            "text": "Welcome back! Today, my guest is the renowned chef, Jean-Pierre."
        }
    ]
}

# 2. Retrieve the adapter for the schema and target format
adapter = get_adapter("audio-transcription", "srt")

# 3. Export to the target format (.srt)
srt_string = adapter.export(transcription)
print(srt_string)

# 4. Parse the formatted string back into a Dorsal record
parsed_record = adapter.parse(srt_string)

Tip: You can programmatically check what formats are supported for a given schema using list_formats:

from dorsal_adapters.registry import list_formats
print(list_formats("document-extraction"))

Contributing

We welcome contributions! If you have written a translation script for an Open Validation Schema, please open a PR.

License

Dorsal Adapters is open source and provided under the Apache 2.0 license.

Release files for dorsalhub-adapters 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dorsalhub-adapters 0.4.1
File Size Uploaded
dorsalhub_adapters-0.4.1.tar.gz 42.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dorsalhub-adapters 0.4.1
File Interpreter ABI Platform
dorsalhub_adapters-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 88.0 kB

Release files / dorsalhub_adapters-0.4.1.tar.gz

Download URL dorsalhub_adapters-0.4.1.tar.gz
Size 42.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3abf0b30407f3b4a31fe9184e3fcefe368f3e69be9a74f658247fc901ed2d30c
BLAKE2b-256 checksum
How to use checksums
95c81702788a6579b219711f6a6d94b52b6be56c0b4885218efc3771f586aa92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.11

Release files / dorsalhub_adapters-0.4.1-py3-none-any.whl

Download URL dorsalhub_adapters-0.4.1-py3-none-any.whl
Size 45.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
edc4fbb1caefba601a7c64b64c62cdcbeaf2cff39d8364b674db9e29065ffe33
BLAKE2b-256 checksum
How to use checksums
d333b6235942c071c4114167b4757dafaefedf0dae6fd33e180b5be0d9cce46e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.11

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page