Skip to content

fix: take filter_expr into account in dependency parsing evaluation #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Support packaging with poetry 2.0
- Solve pickling issues with multiprocessing when pytorch is installed
- Allow deep attributes like `a.b.c` for `span_attributes` in Standoff and OMOP doc2dict converters
- Take `filter_expr` into account in dependency parsing evaluation

# v0.15.0 (2024-12-13)

Expand Down
3 changes: 3 additions & 0 deletions edsnlp/metrics/dep_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def dependency_parsing_metric(
examples = [eg for eg in examples if filter_fn(eg.reference)]

for eg_idx, eg in enumerate(examples):
if filter_expr and not eval(filter_expr, {}, eg):
continue

for token in eg.reference:
items["uas"][0].add((eg_idx, token.i, token.head.i))
items["las"][0].add((eg_idx, token.i, token.head.i, token.dep_))
Expand Down
1 change: 1 addition & 0 deletions tests/training/dep_parser_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ scorer:
speed: false
dep:
'@metrics': "eds.dep_parsing"
filter_expr: "doc.text != ''"

# 🎛️ OPTIMIZER
optimizer:
Expand Down
Loading