def test_remove_restore_phones(text): separator = Separator(phone=';', syllable='_', word=' ') s = Syllabifier(['foo'], ['bar'], separator=separator) clean, index = s._remove_phone_separators(text) assert not re.search(separator.phone, clean) restored = s._restore_phone_separators(clean, index, strip=False) assert restored == text
def test_remove_phones(): separator = Separator(phone=' ', syllable=';esyll', word=';eword') s = Syllabifier(['foo'], ['bar'], separator=separator) text = 'a b ;ewordc ;eword' clean, index = s._remove_phone_separators(text) assert clean == 'ab;ewordc;eword' assert index == [[1, 1], [1]] separator = Separator(phone=';', syllable='_', word=' ') s = Syllabifier(['foo'], ['bar'], separator=separator) text = 'a;b; c;' clean, index = s._remove_phone_separators(text) assert index == [[1, 1], [1]] assert clean == 'ab c' separator = Separator(phone=';', syllable='_', word=' ') s = Syllabifier(['foo'], ['bar'], separator=separator) text = 'ab c' clean, index = s._remove_phone_separators(text) assert index == [] assert clean == 'ab c'