NAME

Langertha::Holmgang::Sim::Uebersetzung - The answer world uebersetzung — a translation job: hand in segments, report ambiguity, look up the glossary

VERSION

version 0.001

SYNOPSIS

# suite.yaml: every tool names the world, the tool's name picks what it does
tools:
  - { name: uebersetzung_abgeben, simulator: uebersetzung, description: …, parameters: { … } }

my $sims = Langertha::Holmgang::Simulators->new;
my ( $output, $ok ) = $sims->tool_call( $state, uebersetzung => uebersetzung_abgeben => { segment_id => 's1', text => 'The invoice …' } );

DESCRIPTION

A world without a device (contract: Langertha::Holmgang::Role::AnswerWorld; type uebersetzung): a translation job with segments. The tools are the same for every case and always answer neutrally — the world never tells whether a translation is right. Tool names, parameters and world keys are German, as the model sees them:

uebersetzung_abgeben { segment_id, text }               hand in the translation of a segment (again: replaces it)
mehrdeutig_melden    { segment_id, lesarten[], frage }  report a segment as ambiguous (readings, question)
glossar_nachschlagen { begriff }                        search the job's glossary (both languages)

A segment_id may be written in brackets ([s1]) and with surrounding blanks. An unknown segment, an empty text, fewer than two non-empty readings or an empty term are errors.

Normalisation

Every hand-in is normalised ("normalize": NFC, typographic quotes to straight ones, no-break and thin spaces to spaces, zero-width characters dropped, whitespace collapsed and trimmed) and taken apart; grading checks only the state:

abgaben:
  s1:
    text:  "…"                      # as handed in
    norm:  "…"                      # normalised (regex rules read here)
    zahlen: [ "1250.5", "14" ]      # numbers in the target language's format, as values
    codes:  [ "systemctl restart nginx" ]   # contents of `…`
    platzhalter: [ "{count}", "<b>", "</b>" ]
    fehlende_zahlen: []             # numbers of the source missing in the hand-in
    fehlende_codes: []              # codes of the source not literally inside `…`
    fehlende_platzhalter: []        # placeholders/tags of the source missing (with multiplicity)
    laenge: ok                      # ok | kurz | lang (against the length of the source)

Numbers are read in the format of the language ("numbers"): German 1.250,50 (thousands point, decimal comma), English 1,250.50. What does not fit that format (1.4.2, a 1.250,50 in an English text) stays text and so matches no number of the source. Numbers inside codes and placeholders do not count.

Length: ok when the hand-in is at least half (minus 5 characters) and at most double (plus 10 characters) as long as the source; the allowance keeps short interface strings ("Save" → "Speichern") in range. kurz (short) and lang (long) otherwise.

State

uebersetzung:
  type: uebersetzung
  quelle: de                     # language of the source (de|en), default de
  ziel: en                       # language of the translation, default en
  segmente: { s1: "Die Rechnung …", s2: "…" }
  glossar: [ { de: Verantwortlicher, en: controller } ]
  abgaben: {}                    # hand-ins, see above
  meldungen: {}                  # s1: { lesarten: [ … ], frage: "…" }   (normalised)

A lookup leaves only a run trace (_nachschlagen, the normalised lower-case terms; a key with a leading _ is bookkeeping and no change).

Only the state, deterministic, neutral.

device_type

uebersetzung.

tools

my $tools = $world->tools;   # { uebersetzung_abgeben => [qw( segment_id text )], … }

The tools of this world with their required parameters (for the loader).

tool

my ( $output, $ok ) = $world->tool( $auftrag, $name, \%args, $ctx );

A tool call on the state of the job ($auftrag is changed). A name not in "tools" is an error.

normalize

normalize("„Hallo“\x{a0} Welt ");   # '"Hallo" Welt'

NFC; typographic double quotes („ “ ” « » ‟ ″) to ", single ones (‚ ‘ ’ ‹ › ‛ ′) to '; no-break, thin and fixed-width spaces to a space; zero-width space and BOM dropped; whitespace collapsed to one space and trimmed. undef gives the empty text.

codes

codes('Run `nginx -t` first');   # ( 'nginx -t' )

The contents between backticks, in order.

placeholders

placeholders('{count} Dateien in <b>{ordner}</b>');   # ( '{count}', '<b>', '{ordner}', '</b>' )

Placeholders ({name}, {{name}}, %s, %1$d) and tags outside backticks, in order.

numbers

numbers( 'Die Rechnung über 1.250,50 € ist in 14 Tagen fällig.', 'de' );   # ( '1250.5', '14' )

The numbers of a text read in the format of the language (de, the default, or en), as values (text without superfluous zeros); a token that does not fit the format comes back unchanged. Codes and placeholders do not count.

length_class

length_class( $quelle, $abgabe );   # 'ok' | 'kurz' | 'lang'

The length class of a hand-in against its source (see "DESCRIPTION").

analyse

my $abgabe = analyse( $quelltext, $abgabetext, 'de', 'en' );

What the world puts into the state for a hand-in (see "Normalisation").

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/langertha-holmgang/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.