File size: 1,007 Bytes
f440f03 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | """Tests datu papildināšanas helperiem."""
from __future__ import annotations
import random
from maris_core.data.augment import back_translate, random_synonym_swap
def test_random_synonym_swap_replaces_known_words_without_losing_punctuation() -> None:
random.seed(7)
augmented = random_synonym_swap("Fast image, good code!", rate=1.0)
assert augmented != "Fast image, good code!"
assert augmented.endswith("!")
assert "," in augmented
def test_random_synonym_swap_returns_original_for_unknown_words() -> None:
assert random_synonym_swap("xyz qwerty", rate=1.0) == "xyz qwerty"
def test_back_translate_uses_language_specific_replacements() -> None:
assert back_translate("Fast help creates a good plan.", lang="en") != (
"Fast help creates a good plan."
)
def test_back_translate_falls_back_to_synonym_swap_for_unknown_language() -> None:
random.seed(3)
augmented = back_translate("Fast image", lang="de")
assert augmented != "Fast image"
|