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']
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']
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']
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'
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']
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']
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']
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 == '!'
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'