コード例 #1
0
def test_class_jtext_alpha_to_full(mocked):
    jtext = kotonoha.Kotonoha()
    jtext.prepare([
        {'alpha_to_full'}
    ])
    jtext.run('kore')
    assert mocked.called
コード例 #2
0
def test_class_jtext_remove_url(mocked):
    jtext = kotonoha.Kotonoha()
    jtext.prepare([
        {'remove_url'}
    ])
    jtext.run('kore')
    assert mocked.called
コード例 #3
0
def test_class_jtext_lower(mocked):
    jtext = kotonoha.Kotonoha()
    jtext.prepare([
        {'lower'}
    ])
    jtext.run('kore')
    assert mocked.called
コード例 #4
0
def test_class_jtext_replace_prices(mocked):
    jtext = kotonoha.Kotonoha()
    jtext.prepare([
        {'replace_prices': {'replace_text': '$'}}
    ])
    jtext.run('kore')
    assert mocked.called
コード例 #5
0
def test_class_jtext_to_full_width(mocked):
    jtext = kotonoha.Kotonoha()
    jtext.prepare([
        {'to_full_width'}
    ])
    jtext.run('kore')
    assert mocked.called
コード例 #6
0
def test_class_jtext_digits(mocked):
    jtext = kotonoha.Kotonoha()
    jtext.prepare([
        {'digits'}
    ])
    jtext.run('kore')
    assert mocked.called
コード例 #7
0
def test_class_jtext_replace_mention(mocked):
    jtext = kotonoha.Kotonoha()
    jtext.prepare([
        {'replace_mentions'}
    ])
    jtext.run('kore')
    assert mocked.called
コード例 #8
0
def test_class_jtext_prepare():
    jtext = kotonoha.Kotonoha()
    list_of_tasks = [
        {'alpha_to_full'},
        {'digits'},
        {'to_full_width'},
        {'lower'},
        {'replace_numbers': {'replace_text': 'n'}},
        {'remove_numbers'},
        {'replace_prices': {'replace_text': '$'}},
        {'remove_prices'},
        {'replace_url': {'replace_text': 'url'}},
        {'remove_url'},
        {'replace_hashtags': {'replace_text': 'hash'}},
        {'replace_emails': {'replace_text': 'email'}},
        {'replace_mentions': {'replace_text': 'mention'}}
    ]
    assert len(list_of_tasks) == len(jtext._operators.keys())
    jtext.prepare(list_of_tasks)
    assert len(jtext._pipeline) == len(list_of_tasks)
コード例 #9
0
def test_class_jtext_prepare_error(caplog):
    with caplog.at_level(logging.ERROR):
        jtext = kotonoha.Kotonoha()
        jtext.prepare([{'non_existing_task'}])
        assert ['Invalid operation: non_existing_task'] == [rec.message for rec in caplog.records]