()
| 232 | |
| 233 | |
| 234 | def test_callback_batch_id(): |
| 235 | # The method will internally sort the input from longest to shortest, |
| 236 | # but we check that the returned batch ids match the user input. |
| 237 | |
| 238 | source = [ |
| 239 | ["ن"] * 1, |
| 240 | ["ن"] * 2, |
| 241 | ["ن"] * 3, |
| 242 | ] |
| 243 | |
| 244 | target_prefix = [ |
| 245 | ["a"], |
| 246 | ["b"], |
| 247 | ["c"], |
| 248 | ] |
| 249 | |
| 250 | def _callback(step_result): |
| 251 | assert step_result.token == target_prefix[step_result.batch_id][0] |
| 252 | return True |
| 253 | |
| 254 | translator = _get_transliterator() |
| 255 | translator.translate_batch( |
| 256 | source, |
| 257 | target_prefix, |
| 258 | max_batch_size=2, |
| 259 | beam_size=1, |
| 260 | callback=_callback, |
| 261 | ) |
| 262 | |
| 263 | |
| 264 | def test_file_translation(tmp_dir): |
nothing calls this directly
no test coverage detected