MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / test_hard_target_prefix

Function test_hard_target_prefix

python/tests/test_translator.py:436–443  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

434
435
436def test_hard_target_prefix():
437 translator = _get_transliterator()
438 output = translator.translate_batch(
439 [["آ", "ت", "ز", "م", "و", "ن"], ["آ", "ت", "ش", "ي", "س", "و", "ن"]],
440 target_prefix=[["a", "t", "s"], None],
441 )
442 assert output[0].hypotheses[0][:3] == ["a", "t", "s"]
443 assert output[1].hypotheses[0] == ["a", "c", "h", "i", "s", "o", "n"]
444
445
446@pytest.mark.parametrize("beam_size", [1, 2])

Callers

nothing calls this directly

Calls 2

_get_transliteratorFunction · 0.85
translate_batchMethod · 0.45

Tested by

no test coverage detected