Skip to content

Arity templates in IntentMappings emit the English word "of" in every language #739

Description

@michaldziwisz

intent_function_glue_before in src/infer_intent.rs returns a hardcoded
English "of" for the last argument of an arity template:

https://github.com/daisy/MathCAT/blob/main/src/infer_intent.rs#L316-L330

// words has arg_count-1 entries for args 1..arg_count-1; last arg is preceded by "of"
if arg_index == arg_count {
    return "of".to_string();
}

So any non-English language that adopts the arity-template form gets an English
word in the middle of its output. Measured in Polish with
"sum": "function=suma | po | od,do":

spoken:   suma po i of x
expected: suma po i, x        (or whatever the language's "of" equivalent is)

The binary-separator form (a single | option, e.g. | divided by) is not
affected, because the separator word itself comes from definitions.yaml.

Consequence today: a translator who follows the documented syntax gets a broken
result, and the working alternative is to not use arity templates. That is what
hu does — "sum": "function=összeg" with no template — and what I ended up
doing for pl in #738 rather than shipping mixed-language speech.

A fix would presumably read the word from the language's rule files, the same way
IntentFunctionArgSeparator resolves comma. I have not attempted it, since it
touches the engine rather than a translation, and I would rather not guess at the
intended design here.

Happy to test a fix against the Polish rules if that is useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions