Esempio n. 1
0
def test_format_word_extra_quote():
    from trigrams import format_word, initialize_state
    state = initialize_state()
    state['in_q'] = True
    next_word, state = format_word('frog', '"', state)
    assert next_word == ''
    assert state['in_q']
Esempio n. 2
0
def test_format_word_out_sentc_end():
    from trigrams import format_word, initialize_state
    state = initialize_state()
    state['in_s'] = False
    next_word, state = format_word('frog', '.', state)
    assert next_word == '.'
    assert not state['in_s']
Esempio n. 3
0
def test_format_word_in_sentc_alpha():
    from trigrams import format_word, initialize_state
    state = initialize_state()
    state['in_s'] = True
    next_word, state = format_word("", 'apple', state)
    assert next_word == ' apple'
    assert state['in_s']
Esempio n. 4
0
def test_format_word_em_dash():
    from trigrams import format_word, initialize_state
    state = initialize_state()
    state['in_s'] = True
    next_word, state = format_word(u'\u2014', 'really', state)
    assert next_word == 'really'
Esempio n. 5
0
def test_format_word_start_brackets():
    from trigrams import format_word, initialize_state
    state = initialize_state()
    next_word, state = format_word('frog', '[', state)
    assert next_word == ' ['
    assert state['in_b']
Esempio n. 6
0
def test_format_word_start_parens():
    from trigrams import format_word, initialize_state
    state = initialize_state()
    next_word, state = format_word('frog', '(', state)
    assert next_word == ' ('
    assert state['in_p']
Esempio n. 7
0
def test_format_word_out_sentc_num():
    from trigrams import format_word, initialize_state
    state = initialize_state()
    next_word, state = format_word("", '18', state)
    assert next_word == ' 18'
    assert not state['in_s']
Esempio n. 8
0
def test_format_word_nls_yes():
    from trigrams import format_word, initialize_state
    state = initialize_state()
    next_word, state = format_word('hop', '!', state)
    assert next_word == '!'
Esempio n. 9
0
def test_format_word_nls_no():
    from trigrams import format_word, initialize_state
    state = initialize_state()
    state['in_s'] = True
    next_word, state = format_word('hop', 'hop', state)
    assert next_word == ' hop'