Skip to main content
Home

Task of the XML files translator supporting vocabulary and preserving input files structure

ATRIUM - LINDAT XML Translation Workflow

Overview The atrium-translator is a modular Python wrapper developed to interface seamlessly with the LINDAT Translation API. This tool is strictly optimized for processing XML documents and their direct derivatives, specifically focusing on ALTO XML documents and AMCR metadata records. It safely translates structural text while maintaining the complex schema and namespaces of the original files.

Core Translation Pipeline Logic The translation workflow follows a structured pipeline designed to protect context, formatting, and domain terminology:

Language Detection: The text undergoes source language identification using Facebook's FastText models. If the confidence score is below 0.2, the system utilizes an intelligent fallback and defaults to Czech (cs) to prevent pipeline interruptions.

Tag-and-Protect Vocabulary Strategy: To ensure domain-specific terminology is not garbled by the Neural Machine Translation (NMT) model, users can supply a vocabulary CSV. Multi-word phrases are matched via case-insensitive substring matching (favoring the longest match first). Single-word terms are matched by their underlying lemma using the LINDAT UDPipe API. These matched terms are replaced with temporary TERM_N placeholder tags prior to the API call, bypassing translation, and are restored to their specified target language equivalents afterward.

Space-Aware Chunking: When dispatching text to the LINDAT Translation API (v2), the script intelligently segments text larger than 4,000 characters at the nearest space. This protects word boundaries and prevents API truncation errors.

Specialized Operating Modes

  1. ALTO XML Mode Triggered via the --alto flag, this mode is explicitly built for OCR/ALTO transcription documents. It natively traverses down to the String level and extracts the CONTENT attributes. Instead of translating word-by-word (which loses context), it reconstructs the entire TextLine for API submission, and carefully redistributes the translated output back into the individual CONTENT attributes.

  2. AMCR Metadata Mode Designed to safely modify structured archaeological and cultural heritage metadata without breaking XML validation. Target elements are dynamically specified via a list of XPaths (e.g., amcr-fields.txt). It features deep recursive namespace extraction to navigate complex OAI-PMH XML envelopes safely. Outputs can be actively validated against a provided XSD schema (e.g., the AISCR schema) to guarantee structural integrity post-translation.

Quality Assurance & Data Provenance To support scientific integrity and ease of review, the tool automatically generates comprehensive provenance data:

Line-by-Line CSV Logging: A supplementary QA CSV log (original_filename_log.csv) is written alongside every output file, allowing researchers to manually cross-reference the text_source_lang directly with the text_target_lang on a per-line or per-XPath basis.

Paradata JSON Logs: A ParadataLogger captures run-level provenance metadata, aggregating counts, timing, processed formats, and skipped files into a serialized JSON file within a dedicated paradata directory.

Additional Utilities Automated Vocabulary Harvesting: The repository includes a helper script (load_vocab.py) that can programmatically download and merge Czech-to-English domain vocabularies from both the AMCR OAI-PMH API and the TEATER GraphQL API into a ready-to-use CSV format.

European Union flag

The SSH Open Marketplace is maintained and will be further developed by three European Research Infrastructures - DARIAH, CLARIN and CESSDA - and their national partners. It was developed as part of the "Social Sciences and Humanities Open Cloud" SSHOC project, European Union's Horizon 2020 project call H2020-INFRAEOSC-04-2018, grant agreement #823782.

CESSDACLARINDARIAH-EU