Skip to content

Commit

Permalink
Merge 1cc2b2c into 66e12d8
Browse files Browse the repository at this point in the history
  • Loading branch information
EPedrotti committed Mar 6, 2019
2 parents 66e12d8 + 1cc2b2c commit 02e04c0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -43,9 +43,12 @@ Removed

Fixed
-----
- do_extractors_support_overlap now correctly throws an exception only if no extractors are passed or if extractors that do not
support overlapping entities are used.

[0.14.3] - 2019-02-01
^^^^^^^^^^^^^^^^^^^^^
-

Changed
-------
Expand Down
4 changes: 3 additions & 1 deletion rasa_nlu/test.py
Expand Up @@ -529,7 +529,9 @@ def determine_token_labels(token, entities, extractors):
def do_extractors_support_overlap(extractors):
"""Checks if extractors support overlapping entities
"""
return extractors is None or CRFEntityExtractor.name not in extractors
if extractors is None:
return False
return CRFEntityExtractor.name not in extractors


def align_entity_predictions(targets, predictions, tokens, extractors):
Expand Down
16 changes: 13 additions & 3 deletions tests/base/test_evaluation.py
Expand Up @@ -4,6 +4,8 @@

import pytest

from rasa_nlu.extractors.mitie_entity_extractor import MitieEntityExtractor
from rasa_nlu.extractors.spacy_entity_extractor import SpacyEntityExtractor
from rasa_nlu.test import (
is_token_within_entity, do_entities_overlap,
merge_labels, remove_duckling_entities,
Expand Down Expand Up @@ -175,19 +177,27 @@ def test_entity_overlap():

def test_determine_token_labels_throws_error():
with pytest.raises(ValueError):
determine_token_labels(CH_correct_segmentation,
determine_token_labels(CH_correct_segmentation[0],
[CH_correct_entity,
CH_wrong_entity], ["CRFEntityExtractor"])


def test_determine_token_labels_no_extractors():
with pytest.raises(ValueError):
determine_token_labels(CH_correct_segmentation[0],
[CH_correct_entity, CH_wrong_entity], None)


def test_determine_token_labels_no_extractors_no_overlap():
determine_token_labels(CH_correct_segmentation[0],
[CH_correct_entity, CH_wrong_entity], None)
EN_targets, None)


def test_determine_token_labels_with_extractors():
determine_token_labels(CH_correct_segmentation[0],
[CH_correct_entity, CH_wrong_entity], ["A", "B"])
[CH_correct_entity, CH_wrong_entity],
[SpacyEntityExtractor.name,
MitieEntityExtractor.name])


def test_label_merging():
Expand Down

0 comments on commit 02e04c0

Please sign in to comment.