diff --git a/changelog.md b/changelog.md index 7916c7f5f..444637db3 100644 --- a/changelog.md +++ b/changelog.md @@ -16,6 +16,7 @@ - The Span value extension is not more forcibly overwritten, and user assigned values are returned by `Span._.value` in priority, before the aggregated `span._.get(span.label_)` getter result (#220) - Enable mmap during multiprocessing model transfers - `RegexMatcher` now supports all alignment modes (`strict`, `expand`, `contract`) and better handles partial doc matching (#201). +- `on_ent_only=False/True` is now supported again in qualifier pipes (e.g., "eds.negation", "eds.hypothesis", ...) ## v0.10.0 diff --git a/edsnlp/pipes/qualifiers/base.py b/edsnlp/pipes/qualifiers/base.py index 7d669b191..0d4fd504d 100644 --- a/edsnlp/pipes/qualifiers/base.py +++ b/edsnlp/pipes/qualifiers/base.py @@ -92,14 +92,14 @@ def __init__( on_ents_only = True if on_ents_only: + assert span_getter is None or on_ents_only is True, ( + "Cannot use both `span_getter` and `on_ents_only` as a span selection " + "argument." + ) assert isinstance(on_ents_only, (list, str, set, bool)), ( "The `on_ents_only` argument should be a " "string, a bool, a list or a set of string" ) - - assert span_getter is None, ( - "Cannot use both `on_ents_only` and " "`span_getter`" - ) span_getter = "ents" if on_ents_only is True else on_ents_only else: span_getter = "ents" diff --git a/tests/pipelines/qualifiers/test_negation.py b/tests/pipelines/qualifiers/test_negation.py index 29d125d1e..7e429e8c7 100644 --- a/tests/pipelines/qualifiers/test_negation.py +++ b/tests/pipelines/qualifiers/test_negation.py @@ -2,7 +2,7 @@ from pytest import fixture, mark -from edsnlp.pipelines.qualifiers.negation import Negation +from edsnlp.pipes.qualifiers.negation import Negation from edsnlp.utils.examples import parse_example negation_examples: List[str] = [ @@ -32,7 +32,6 @@ @fixture def negation_factory(blank_nlp): - default_config = dict( pseudo=None, preceding=None, @@ -42,10 +41,10 @@ def negation_factory(blank_nlp): attr="NORM", within_ents=False, explain=True, + span_getter="ents", ) def factory(on_ents_only, **kwargs) -> Negation: - config = dict(**default_config) config.update(kwargs) @@ -60,7 +59,6 @@ def factory(on_ents_only, **kwargs) -> Negation: @mark.parametrize("on_ents_only", [True, False]) def test_negation(blank_nlp, negation_factory, on_ents_only): - negation = negation_factory(on_ents_only=on_ents_only) for example in negation_examples: @@ -74,9 +72,7 @@ def test_negation(blank_nlp, negation_factory, on_ents_only): doc = negation(doc) for entity, ent in zip(entities, doc.ents): - for modifier in entity.modifiers: - assert bool(ent._.negation_cues) == (modifier.value in {True, "NEG"}) assert ( @@ -91,7 +87,6 @@ def test_negation(blank_nlp, negation_factory, on_ents_only): def test_negation_within_ents(blank_nlp, negation_factory): - negation = negation_factory(on_ents_only=True, within_ents=True) examples = [ @@ -109,9 +104,7 @@ def test_negation_within_ents(blank_nlp, negation_factory): doc = negation(doc) for entity, ent in zip(entities, doc.ents): - for modifier in entity.modifiers: - assert bool(ent._.negation_cues) == (modifier.value in {True, "NEG"}) assert (