Skip to content

Linguistic annotation and named entities, kept on the page

The nlp-enrich workflow. Tool: atrium-nlp-enrich.

Purpose

Searching and linking archival documents needs more than their raw text: the base form of each word, its part of speech, the structure of the sentence, and the people, places and organisations it names. In the AMČR pipeline this workflow reads the document's ATRIUM record, which ocr-postprocess builds: its lines are the text, and their boxes the page layout. It sends the text to LINDAT's UDPipe 2 and NameTag 3 services, merges their answers, and adds the linguistic layer and the named entities to the record. It also writes the document as TEITOK XML, a TEI-based format that keeps every word tied to its place on the page image, with CoNLL-U and tables beside it. For research collections the same stages run over tables of text lines, with the OCR's ALTO files or a TEITOK file converted by flexiconv as the layout.

At a glance

In the document's ATRIUM record (JSON, schema 2.0), whose lines are the text and whose line boxes and blocks are the layout. For research and batch use: tables of text lines (CSV or XLSX with a text column, such as ocr-postprocess's), plain text (.txt, a form feed starting a page) or inline lines; optionally, for word positions, the original ALTO files or a TEITOK file converted by flexiconv, and the page images
Out the record with each line's lemma, part of speech, features and TEITOK reference, each page's TEITOK surface, and its entities block; TEITOK XML (teitok-2); CoNLL-U per document; named entities per page (TSV); tokens, lemmas and entities per document (CSV); an entity summary for the collection (CSV); paradata (JSON); over HTTP, a JSON envelope or a ZIP of these files
Runs as an HTTP service image, atrium-nlp-enrich-api (/enrich, /enrich_text, /jobs, /rescale, /project_record); a command-line pipeline (four stage scripts, or run_pipeline.py) and its batch image; an Agent Skill
Compute CPU; the annotation itself runs on LINDAT's servers
Network the LINDAT UDPipe 2 and NameTag 3 services on every run, or self-hosted ones set by UDPIPE_URL and NAMETAG_URL; no model is downloaded
Code licence MIT
Component licences the UDPipe 2 and NameTag 3 models (CC BY-NC-SA 4.0), through the LINDAT services and under their terms of use, on every run; the optional converter flexiconv (MIT). No licence of an output is computed: Licences and paradata
Record SSH Open Marketplace tool EMhu3X

Steps

# Step What happens In → out Activity
1 Collect the text The lines of each document are put in page and line order into one text per document. From a record: its lines with text, less those ocr-postprocess categorised Trash or Empty. From a table: all its rows, or on request (--skip-untrustworthy-lines, skip_untrustworthy_lines) all but its Trash rows. A rows file keeps the page and line of every line, and a manifest lists the documents. JSON, CSV, XLSX, TXT → TXT, TSV Preprocessing
2 Morphology and syntax UDPipe 2, with its Czech model (czech-pdt-ud-2.15-241121), tokenises the text and adds lemmas, part-of-speech tags, morphological features and dependency syntax. A long text is sent in pieces of up to 900 words, cut at line ends, and the answers are joined again. TXT → CoNLL-U Lemmatizing, POS-Tagging, Parsing
3 Named entities NameTag 3, with its general multilingual model (nametag3-multilingual-onto-260521), finds names of people, places, organisations and other entities in the annotated text, and writes them page by page; the pages come from the rows file. CoNLL-U → TSV Named Entity Recognition
4 Merge and write Tokens, lemmas and entities are joined per document into tables, into CoNLL-U with the entities added, and into TEITOK XML (teitok-2). With a layout, each word in TEITOK carries its box on the page; without one, TEITOK keeps the pages and lines of the text. Every TEITOK file must pass the format's contract, its XSD and its rules for identifiers, references and pages, before the stage ends. With a record, each line gets the lemma, part of speech and features of its head word, and the record gets the entities. CoNLL-U, TSV (+ record, ALTO, TEITOK) → CSV, CoNLL-U, TEITOK XML (+ record) Encoding
5 Record provenance Each stage writes a paradata log, and a whole-pipeline run merges them into one run summary. Over HTTP the paradata come back with the answer: the record read, and the record and the TEITOK file written. → JSON —

The layout of a document comes from its ALTO file; else from a TEITOK file that flexiconv converted; else from its record. In the AMČR pipeline only the record is used: no ALTO is produced or stored. The record has the size of each page and a box for each line, so word boxes are shared out from the line boxes by character offset and are approximate. A line whose box is only its block's gets none. The boxes are in the record's coordinate space, PDF points: the command line scales them to the page images (INPUT_PAGES_DIR) or to a resolution (IMAGE_DPI), and the service returns them in points. A record without boxes, a spreadsheet's or a text file's, gives the pages and lines only. A layout that is there but cannot be carried in full, such as an unreadable or partial ALTO, boxes on a page of unknown size or (from 2.0.2-beta, on test) more than one unit off their page, or text of which less than 90 % aligns to the layout, fails the document rather than giving a TEITOK file without its boxes or with boxes moved. A coordinate off by one unit, the rounding of a scale, is snapped onto the page and noted in the TEITOK header.

Rescaling. POST /rescale (or fix_teitok_bboxes.py on the command line) rewrites the boxes of a finished TEITOK file for page images of another size, page by page. For the points of a record, give scale = the images' DPI / 72. From 2.0.2-beta, a box that would land more than one unit off its page refuses the file (422; exit 5), which is left as it was. Its answer carries the call's paradata, as /project_record's does, and the script writes them beside each file it rewrites.

When a run stops, the runner's exit code says why, and the service answers with the matching HTTP status. LINDAT not answering after its retries is exit 6 (502 upstream_unavailable); every attempt timing out is exit 7 (504); LINDAT refusing the request, such as for an unknown model, is exit 8 (500). A TEITOK file that fails its contract is exit 5 (500), a writer defect; a layout that cannot be carried in full is exit 5 too, answered 422. Before the first stage the runner checks that the stages' python3 can import what they need; if it cannot, it stops with exit 3 (500) and says how to fix it. A record that was asked for and not written fails the run as well (exit 1, 502), and so do run paradata that cannot be written (exit 1, 500). With --force the runner still runs the stages after a failed one, then exits with the first failure's code. The usage guide's exit codes list them all.

Optional stages. Documents that are not ALTO, such as PDF, office files, PAGE XML or hOCR, can be converted into TEITOK by flexiconv on the command line, then annotated like a table (Pipelines → W11). The opt-in projection /project_record copies the finished record's page categories and keywords into the TEITOK header. It reads what keyword-extract wrote, so it runs after that step, and its result is not stored: AMČR's TEITOK file keeps the linguistics and the layout only.

What you get

  • The enriched record — document_json in the service's answer, or the file --document-json-out names. Its entities block gives each entity's type, page, line and box, and points at its <name> in the TEITOK file (teitok_ref). Each line gets the lemma, part of speech and features of its head word, and each page its surface in the TEITOK file.
  • The document in TEITOK — TEITOK/<doc>.teitok.xml, or teitok_xml over HTTP: every word a <tok> with its lemma and tags and, where the layout gives one, its box. Its header says where the text and the boxes came from.
  • CoNLL-U and tables — UDP_NE/<doc>/<doc>.conllu with the entities added, UDP_NE/<doc>/<doc>.csv with the tokens, lemmas and entities, NE/<doc>/<doc>-<page>.tsv per page, and summary_ne_counts.csv for the collection.
  • A provenance record — one <run_id>-<8 hex>_nlp-enrich.json per stage and the merged <run_id>-<8 hex>_nlp-enrich_pipeline-run.json, or the paradata of the service's answer (in a ZIP answer, paradata/<doc_id>.create-action.json).

Every output file is listed in Reference → Outputs, and the TEITOK structure in Reference → TEITOK.

In the AMČR pilot the TEITOK file is stored as atr/teitok-xml, and the record goes on to keyword-extract. Until the terms of LINDAT's services are settled (atrium-project#78), AMČR does not publish outputs made through them: the linguistic layer, the entities, the TEITOK file and the English metadata.

Limits

  • Czech only. Both entry points take cs only, with UDPipe's Czech model. Named entities come from NameTag's general multilingual OntoNotes model, not an archaeological one, so its entity types are general.
  • LINDAT is required. Every run sends the text to LINDAT's UDPipe 2 and NameTag 3, or to the instances UDPIPE_URL and NAMETAG_URL name; there is no local fallback. Without them a run stops after its retries, about a minute, and the service answers 502 or 504. Nothing partial is returned.
  • Word positions are estimates. A record has line boxes at best, so its word boxes are shared out from the line geometry. A line whose box is only its block's, ATR text without line breaks, gets no coordinates, and the TEITOK header says how many.
  • Points, not pixels. A record's boxes are in PDF points; /rescale with scale = DPI/72 turns them into the pixels of a page image rendered at that resolution.
  • Service limits. An upload over 5 MB a part (MAX_UPLOAD_MB) or 30,000 words (MAX_WORDS) is refused with
  • By default two runs work at a time and eight jobs wait; past them the service answers 429. A run longer than API_JOB_TIMEOUT (600 s) is stopped with 504 (Limits).
  • Background jobs are not durable. A /jobs job lives in the memory of the replica that accepted it. A restart or a redeploy loses it (404), and the caller submits it again; /enrich is the synchronous alternative.
  • flexiconv runs on the command line only. The service takes its output but never runs it, so other formats are converted before they are sent.
  • Not evaluated here. The tests check the pipeline, the formats and the contracts, not the accuracy of UDPipe or NameTag on archival documents; a person checks the annotation that matters.

Provenance and licence

Each stage writes a paradata log, <run_id>-<8 hex>_nlp-enrich.json, and a whole-pipeline run merges them into one run summary. Over HTTP the run's paradata come back with the answer, as a Process Run Crate action (paradata): the record read and the record and TEITOK file written, as AMČR distributions by name and SHA-512. The paradata list the components a run used, each with its licence or terms, as declared in the tool's para_config.txt:

Component Licence Used when
NameTag 3 model, multilingual OntoNotes by default (nametag3_models) CC BY-NC-SA 4.0 every run
UDPipe 2 Czech model, czech-pdt UD (udpipe2_models) CC BY-NC-SA 4.0 every run
flexiconv, the document-to-TEITOK converter (flexiconv) MIT documents were converted to TEITOK (command line)

Both models run at LINDAT under the LINDAT Terms of Use; a run records the services it called by their address and model name in its settings (config). The engines behind them, UDPipe 2 and NameTag 3 (MPL 2.0), are declared in para_config.txt but not listed by a run. Each run lists the components it used, each with its own licence or terms. No licence of an output is computed: the rights in an output follow the source document (Licences and paradata).

In the document record the tool owns the entities block and each line's lemma, upos, feats and teitok_ref. They give the lemma, part of speech and features of the line's head word, and the sentence it belongs to in the TEITOK file. Each entity points at its <name> in the TEITOK file (teitok_ref), and each page with a surface at its <surface> (pages[].teitok_surface). The record carries no run data.

Where it sits

  • After ocr-postprocess, the record builder, in the AMČR pipeline. The record's lines are its text, and their boxes the TEITOK file's layout, whether the lines came from a born-digital text layer, the ATR (AIS CR's text-recognition service) or both. keyword-extract follows it and reads the record it leaves — Pipelines → The route through the pipeline and W1.
  • The production service of its step, the image ghcr.io/ufal/atrium-nlp-enrich-api — Pipelines → W4.
  • Linguistic annotation and named entity recognition step of the AMČR text workflow 0xSpVP.
  • Also used in W5 (from a coding agent), W6 (the scanned end-to-end lane) and W11 (format adaptation into TEITOK).

On other platforms

SSH Open Marketplace. Tool record EMhu3X. The LINDAT services it calls have their own records, UDPipe and NameTag, and so does the corpus platform whose format it writes, TEITOK.

Galaxy sheet. The Galaxy wrappers were handed to DARIAH for testing; further Galaxy work is parked during the AMČR pilot. The sheet describes the wrapper as the hub's galaxy/ folder holds it, at 2.0.1-beta+galaxy0.

Workflow inputs a line table — csv with a text column (the line table of ocr-postprocess), or txt, xlsx; optionally its ALTO — xml; a document record to add to — json
Parameters whether the lines marked untrustworthy are left out; the four stages always run and TEITOK is always written
Workflow outputs CoNLL-U with NER= per word — tabular (no conllu datatype on DARIAH's Galaxy); tokens — csv; entities per page — csv; TEITOK — tei; paradata — json; document record — json
Container ghcr.io/ufal/atrium-nlp-enrich:<version> — the batch image (run_pipeline.py); it runs the job script Galaxy hands it (the hub-canonical container_entrypoint.py). Its paths come only from a config file, so a job script writes one with absolute paths. The service image -api is not used
Galaxy tool atrium_nlp_enrich 2.0.1-beta+galaxy0, in the hub's galaxy/ folder with the workflow ATRIUM OCR to keywords; for DARIAH's test Galaxy (https://galaxy.acdh-dev.oeaw.ac.at/galaxy/)
Compute CPU
Network outbound HTTPS to LINDAT UDPipe (czech-pdt-ud-2.15-241121) and NameTag 3 (nametag3-multilingual-onto-260521); Czech only
Credentials none
Test data one of the synthetic documents in data_samples/ — its line table and ALTO — the line table the ocr-postprocess wrapper writes for a two-page CSV, and a table without a text column for the error test
Credit the authors in the tool's CITATION.cff, with their ORCIDs; licence MIT
Closest Galaxy tools stanza_nlp, which tokenises, tags, parses and finds named entities with local models; UDPipe and NameTag themselves have been wrapped for Galaxy before, as tools calling LINDAT's services

Sources

Read from ufal/atrium-nlp-enrich at release v2.0.1-beta (tagged 2 December 2026), from its last pull request, on 2026-12-02; what is marked "from 2.0.2-beta" was read from its test of 3 December 2026 (the v2-beta-d13 pull request). Earlier readings were at v2.0.0-beta (328da74, 2026-11-29), of test before that release (2026-11-21), and at v1.3.0-beta (2026-10-29), v1.2.0-beta (2026-10-26) and v1.1.2-beta (2026-10-19). The Galaxy sheet (2026-12-02) follows 2.0.1-beta+galaxy0 and the hub's galaxy/ folder. This table records provenance, not a build instruction.

Source What was taken from it
README.md, docs/how-it-works.md, docs/usage.md §§ Run the whole pipeline, Exit codes, Convert other input formats with flexiconv, The command line and the service purpose, the step order, the layouts, the exit codes, the limits
service/README.md §§ Endpoints, Layout inputs, POST /rescale, POST /project_record, Limits, Partial results, Known limits, How it works the HTTP service, rescaling, the projection, the limits, exit codes as HTTP
run_pipeline.py, api_1_manifest.sh … api_4_stats.sh, api_flexiconv.sh the stages, the preflight, the exit codes
api_util/record_layout.py, line_inputs.py, lindat_errors.py, bbox_scale.py, document_hook.py the record as text and layout, the input reader shared with the service, the LINDAT exit codes, the points, the record fields
docs/reference/outputs.md, docs/reference/teitok.md, docs/reference/paradata.md the outputs, the TEITOK structure, the paradata and their file names
para_config.txt, docs/reference/licences.md the licence components, the services' terms
config_api.txt the backing-service endpoints and models
Dockerfile, .github/production-image.json the images
CITATION.cff, CONTRIBUTING.md § Release History the release and its date
data_samples/ test data
SSH Open Marketplace EMhu3X, i6piia, nMF4rm, RK2Kb3 the record identifiers
the hub's galaxy/tools/atrium_nlp_enrich/ and galaxy/workflows/atrium_ufal/ (workflows 0.5.0) the Galaxy sheet
galaxyproject/tools-iuc (stanza); lappsgrid-incubator/GalaxyMods (tools/lindat) the Galaxy analogues