fix: set-list zip produces incorrect span pairings in PerClassScorer (candidate_generation.py)
- 主要語言
- Python
- 星號
- 2k
- 分支
- 258
- PR 合併指標
- 30 天內沒有已合併 PR
描述
## Problem
In `scispacy/per_class_scorer.py` line 21-23, `untyped_predicted_spans` is constructed as a **set**:
```python
untyped_predicted_spans = {(x[0], x[1]) for x in predicted_spans}
```
Then on line 23, it is **zipped** with the original list:
```python
for untyped_span, span in zip(untyped_predicted_spans, predicted_spans):
```
**Sets do not preserve insertion order in Python.** This means the `untyped_span` variable may not correspond to the correct `span` from `predicted_spans`. The result is that the untyped TP/FP counting (lines 30-34) can attribute matches to the wrong spans, producing incorrect untyped precision/recall metrics.
## Proposed Fix
Change the set comprehension to a list comprehension (or compute the untyped span inline):
```python
untyped_predicted_spans = [(x[0], x[1]) for x in predicted_spans]
```
## Affected File
`scispacy/per_class_scorer.py`
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。