Skip to content

Batch Extraction Examples

These examples are derived directly from alef’s cross-language fixture corpus and are kept in sync with the generated snippet tree automatically — no per-language import list to maintain.

Extract multiple in-memory documents in one batch.

Python
import asyncio
from pathlib import Path
from xberg import extract_batch
async def main() -> None:
inputs = [{"bytes": [72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33], "kind": "bytes", "mime_type": "text/plain"}, {"bytes": "html/html.html", "kind": "bytes", "mime_type": "text/html"}]
result = await extract_batch(inputs)
print(result.results)
asyncio.run(main())

Batch-extract with an unsupported MIME type

Section titled “Batch-extract with an unsupported MIME type”

extract_batch with unsupported bytes MIME type

Python
import asyncio
from xberg import extract_batch
async def main() -> None:
inputs = [{"bytes": [100, 97, 116, 97], "kind": "bytes", "mime_type": "application/x-unknown"}]
result = await extract_batch(inputs)
print(result)
asyncio.run(main())