发布

  • 2.1.2 4102695fa5

    [NA] [SDK] fix: forward char_order and ignore_whitespace to NLTK in ChrF metric (#7230)

    frostbyte_neo 发布于 2026-06-25 08:54:31 +00:00

    • fix: forward char_order and ignore_whitespace to NLTK in ChrF metric

    The ChrF metric stored char_order and ignore_whitespace but only passed beta
    to nltk.translate.chrf_score.sentence_chrf, so those parameters were silently
    ignored (and ignore_whitespace's documented default of False was overridden by
    NLTK's own default of True). Forward char_order as max_len and ignore_whitespace
    to NLTK. Clarify in the docstring that word_order (chrF++) is not supported by
    the NLTK backend and requires a custom chrf_fn. Add a regression test asserting
    the parameters are forwarded.

    • test: exercise ChrF config through the public API and follow naming convention

    Address review: rename the test to the test_WHAT__CASE__EXPECTED pattern and
    assert on public ChrF.score output (scores change when char_order /
    ignore_whitespace vary) instead of inspecting the internal NLTK backend call
    args. Gated with importorskip('nltk') since the NLP backend is optional and not
    a test dependency.

    • fix: default ChrF ignore_whitespace to True to preserve prior behaviour

    Address review: before forwarding the flag, NLTK's own default (True) always
    applied, so whitespace was effectively ignored. Defaulting to True keeps results
    stable for users who relied on that implicit behaviour across an Opik update.

    下载附件