Exemplo n.º 1
0
def test_get_entities_from_tags_where_sys_entity_between_entities(
        kwik_e_mart_nlp, query, tags):
    """Tests the behavior when a system entity is between two entities"""

    processed_query = kwik_e_mart_nlp.create_query(query)
    res_entity = taggers.get_entities_from_tags(processed_query, tags)
    assert len(res_entity) == 4
Exemplo n.º 2
0
def test_get_entities_from_tags_where_entity_truncated_by_new_entity(
        kwik_e_mart_nlp, query, tags):
    """Test the behavior when a new entity is directly after another entity"""

    processed_query = kwik_e_mart_nlp.create_query(query)
    res_entity = taggers.get_entities_from_tags(processed_query, tags)
    assert len(res_entity) == 2
Exemplo n.º 3
0
def test_get_entities_from_tags_with_multi_token_entities(
        kwik_e_mart_nlp, query, tags):
    """Tests the behavior with multi token entities"""

    processed_query = kwik_e_mart_nlp.create_query(query)
    res_entity = taggers.get_entities_from_tags(processed_query, tags)
    assert len(res_entity) == 2
Exemplo n.º 4
0
def test_get_entities_from_tags_where_entities_end_with_query_end(
        kwik_e_mart_nlp, query, tags):
    """Tests the behavior when the entity is at the end of a query"""

    processed_query = kwik_e_mart_nlp.create_query(query)
    res_entity = taggers.get_entities_from_tags(processed_query, tags)
    assert len(res_entity) == 1
Exemplo n.º 5
0
def test_get_entities_from_tags_where_tag_idx_not_in_sys_candidate(
        kwik_e_mart_nlp, query, tags):
    """Tests the behavior when the system entity tag index is outside
    the system candidates spans"""

    processed_query = kwik_e_mart_nlp.create_query(query)
    res_entity = taggers.get_entities_from_tags(processed_query, tags)
    assert res_entity == ()
Exemplo n.º 6
0
def test_get_entities_from_tags_where_tag_idx_in_sys_candidate(
        kwik_e_mart_nlp, query, tags, expected_time):
    """Tests the behavior when the system entity tag index is
    within the system candidates spans"""

    processed_query = kwik_e_mart_nlp.create_query(query, time_zone="UTC")

    res_entity = taggers.get_entities_from_tags(processed_query, tags)

    if res_entity[0].to_dict()["value"]["grain"] == "minute":
        assert res_entity[0].to_dict(
        )["value"]["value"][MINUTE_GRAIN_INDEX:] in set(expected_time)
    else:
        assert res_entity[0].to_dict()["value"]["value"] in set(expected_time)