Skip to content

Commit

Permalink
fix: support qualifiers on_ents_only=False again
Browse files Browse the repository at this point in the history
Co-Authored-By: Thomas Petit-Jean <[email protected]>
  • Loading branch information
percevalw and Thomzoy committed Dec 15, 2023
1 parent 1faf768 commit dd510d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions edsnlp/pipes/qualifiers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 2 additions & 9 deletions tests/pipelines/qualifiers/test_negation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [
Expand Down Expand Up @@ -32,7 +32,6 @@

@fixture
def negation_factory(blank_nlp):

default_config = dict(
pseudo=None,
preceding=None,
Expand All @@ -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)

Expand All @@ -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:
Expand All @@ -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 (
Expand All @@ -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 = [
Expand All @@ -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 (
Expand Down

0 comments on commit dd510d1

Please sign in to comment.