allenai / allenai/ir_datasets

TREC Clinical Document Parsing Logic Bug

Offen
#282 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Python
Sterne
391
Forks
58
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**Describe the bug**
When parsing TREC Clinical XML documents the following [line](https://github.com/allenai/ir_datasets/blob/c13285be41fc0fadeb6a2c7fdb77ff3c350d3b14/ir_datasets/datasets/clinicaltrials.py#L84C8-L84C71) is used:
```
condition = xml.find('.//condition')
condition = ''.join(condition.itertext()) if condition else ''
```
it seems that even when `condition` is a valid node it still evaluates to `False` so that condition is always set to "". Just as a test I added this line:
```
assert bool(condition) == condition is not None
```
after `xml.find` and it fails. The fix is just:
```
condition = ''.join(condition.itertext()) if condition is not None else ''
```
I can raise a PR, but wasn't sure how the tests should be changed.

**Affected dataset(s)**
TREC Clinical 2021 & 2022

**To Reproduce**
Steps to reproduce the behavior:
1. Try parsing a TREC Clinical document with the code from [here](https://github.com/allenai/ir_datasets/blob/c13285be41fc0fadeb6a2c7fdb77ff3c350d3b14/ir_datasets/datasets/clinicaltrials.py#L76).
2. Even if a valid condition tag is present the condition value will be set to "".

**Expected behavior**
The condition tag should be properly read and included in the document.

**Additional context**
Also worth mentioning some documents have multiple condition tags which you might want to include.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.