Ejemplo n.º 1
0
def test_fails_on_duplicate_topic():
    class _BrokenTopic(Enum):
        some, SOME = range(2)

    with pytest.raises(ValueError) as error:
        analysis.Lexicon(_BrokenTopic, _Rating)
    assert error.match(r"^case insensitive name 'some' for enum _BrokenTopic must be unique$")
Ejemplo n.º 2
0
def test_can_read_lexicon_csv(nlp_en: Language, en_restauranteering_csv_path: str):
    lexicon = analysis.Lexicon(_Topic, _Rating)
    lexicon.read_from_csv(en_restauranteering_csv_path)
    assert len(lexicon.entries) >= 1

    clean_token = _token_for(nlp_en, 'clean')
    clean_entry = lexicon.lexicon_entry_for(clean_token)
    assert clean_entry is not None
Ejemplo n.º 3
0
def test_fails_on_adding_lexicon_entry_with_unknown_rating():
    lexicon = analysis.Lexicon(RestaurantTopic, Rating)
    with pytest.raises(ValueError) as error:
        lexicon._append_lexicon_entry_from_row(['x', '', '', 'unknown'])
    assert error.match(r"^name 'unknown' for enum Rating must be one of: .+$")