示例#1
0
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ʃʊ'
示例#2
0
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ʃʊ'
示例#3
0
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ʌ '
示例#4
0
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ʌ '
示例#5
0
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ʃ ʊ'
示例#6
0
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ʃ_ʊ'
示例#7
0
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ʃ ʊ']
示例#8
0
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ʃ ʊ'
示例#9
0
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ʃ_ʊ'
示例#10
0
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ʃ ʊ'
示例#11
0
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ʃ ʊ'
示例#12
0
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'ʌ ', 'ʌ ']
示例#13
0
def test_bad_morpheme():
    backend = SegmentsBackend('cree')
    with pytest.raises(ValueError):
        backend.phonemize('A')
示例#14
0
def test_bad_morpheme():
    backend = SegmentsBackend('cree')
    with pytest.raises(ValueError):
        backend.phonemize('A')