Skip to content

Commit 130264d

Browse files
committed
fix: take filter_expr into account in dependency parsing evaluation
1 parent 18b03a3 commit 130264d

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Support packaging with poetry 2.0
1616
- Solve pickling issues with multiprocessing when pytorch is installed
1717
- Allow deep attributes like `a.b.c` for `span_attributes` in Standoff and OMOP doc2dict converters
18+
- Take `filter_expr` into account in dependency parsing evaluation
1819

1920
# v0.15.0 (2024-12-13)
2021

edsnlp/metrics/dep_parsing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def dependency_parsing_metric(
3333
examples = [eg for eg in examples if filter_fn(eg.reference)]
3434

3535
for eg_idx, eg in enumerate(examples):
36+
if filter_expr and not eval(filter_expr, {}, eg):
37+
continue
38+
3639
for token in eg.reference:
3740
items["uas"][0].add((eg_idx, token.i, token.head.i))
3841
items["las"][0].add((eg_idx, token.i, token.head.i, token.dep_))

tests/training/dep_parser_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ scorer:
2323
speed: false
2424
dep:
2525
'@metrics': "eds.dep_parsing"
26+
filter_expr: "doc.text != ''"
2627

2728
# 🎛️ OPTIMIZER
2829
optimizer:

0 commit comments

Comments
 (0)