def test_separator(): backend = SegmentsBackend('cree') text = 'achi acho' sep = separator.default_separator assert backend.phonemize(text, separator=sep) == u'ʌtʃɪ ʌtʃʊ ' assert backend.phonemize(text, separator=sep, strip=True) == u'ʌtʃɪ ʌtʃʊ'
def test_multiline(): backend = SegmentsBackend('cree') assert backend.phonemize('a') == u'ʌ ' assert backend.phonemize('aa') == u'ʌʌ ' assert backend.phonemize('a\n') == u'ʌ ' assert backend.phonemize('a\na') == u'ʌ \nʌ ' assert backend.phonemize('a\na\n') == u'ʌ \nʌ '
def test_separator_5(): backend = SegmentsBackend('cree') text = 'achi acho' sep = separator.Separator(phone=' ', word='_') assert backend.phonemize(text, separator=sep) == u'ʌ tʃ ɪ _ʌ tʃ ʊ _' assert backend.phonemize(text, separator=sep, strip=True) \ == u'ʌ tʃ ɪ_ʌ tʃ ʊ'
def test_separator_3(): backend = SegmentsBackend('cree') text = 'achi acho' sep = separator.Separator(word=' ', syllable=None, phone='_') assert backend.phonemize(text, separator=sep) == u'ʌ_tʃ_ɪ_ ʌ_tʃ_ʊ_ ' assert backend.phonemize(text, separator=sep, strip=True) \ == u'ʌ_tʃ_ɪ ʌ_tʃ_ʊ'
def test_separator_2(): backend = SegmentsBackend('cree') text = ['achi acho'] sep = Separator(word='_', phone=' ') assert backend.phonemize(text, separator=sep) == [u'ʌ tʃ ɪ _ʌ tʃ ʊ _'] assert backend.phonemize(text, separator=sep, strip=True) \ == [u'ʌ tʃ ɪ_ʌ tʃ ʊ']
def test_separator_4(): backend = SegmentsBackend('cree') text = 'achi acho' # TODO bug when sep.phone == ' ' with no sep.word sep = separator.Separator(phone=' ', word='') assert backend.phonemize(text, separator=sep) == u'ʌ tʃ ɪ ʌ tʃ ʊ ' assert backend.phonemize(text, separator=sep, strip=True) \ == u'ʌ tʃ ɪʌ tʃ ʊ'
def test_multiline(): backend = SegmentsBackend('cree') assert backend.language == 'cree' assert backend.phonemize(['a']) == [u'ʌ '] assert backend.phonemize(['aa']) == [u'ʌʌ '] assert backend.phonemize(['a\n']) == [u'ʌ '] assert backend.phonemize(['a\na']) == [u'ʌ ʌ '] assert backend.phonemize(['a\na\n']) == [u'ʌ ʌ '] assert backend.phonemize(['a', 'a']) == [u'ʌ ', 'ʌ '] assert backend.phonemize(['a\n', 'a\n']) == [u'ʌ ', 'ʌ ']
def test_bad_morpheme(): backend = SegmentsBackend('cree') with pytest.raises(ValueError): backend.phonemize('A')