Skip to content

Commit 078e405

Browse files
added obeservation text (#348)
## Description We currently are not creating candidates from `observation/text`, this adds a case found in the the Powerpoint of reference examples. ## Related Issues Closes #347 ## Additional Notes This is part of the output to #310
1 parent 26f2c9c commit 078e405

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

packages/text-to-code/src/text_to_code/models/eicr.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
class LabXPaths(StrEnum):
88
"""The list of Sub XPath expressions to extract text in various locations from lab elements."""
99

10-
CODE_DISPLAY_NAME = "/code/@displayName"
11-
CODE_ORIGINAL_TEXT = "/code/originalText"
12-
CODE_TEXT = "/text"
13-
CODE_TRANSLATION_DISPLAY_NAME = "/code/translation/@displayName"
14-
CODE_TRANSLATION_ORIGINAL_TEXT = "/code/translation/originalText"
10+
CODE_DISPLAY_NAME = "code/@displayName"
11+
CODE_ORIGINAL_TEXT = "code/originalText"
12+
OBSERVATION_TEXT = "text"
13+
CODE_TRANSLATION_DISPLAY_NAME = "code/translation/@displayName"
14+
CODE_TRANSLATION_ORIGINAL_TEXT = "code/translation/originalText"
1515

1616

1717
class Candidate(BaseModel):

packages/text-to-code/src/text_to_code/models/evaluator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class LabTestNameOrderedEvaluationCriteria(BaseEvaluationCriteria):
132132
XPathPriority(xpath=LabXPaths.CODE_TRANSLATION_DISPLAY_NAME, priority=2),
133133
XPathPriority(xpath=LabXPaths.CODE_ORIGINAL_TEXT, priority=3),
134134
XPathPriority(xpath=LabXPaths.CODE_TRANSLATION_ORIGINAL_TEXT, priority=4),
135+
XPathPriority(xpath=LabXPaths.OBSERVATION_TEXT, priority=5),
135136
]
136137
)
137138

@@ -162,6 +163,7 @@ class LabTestNameResultedEvaluationCriteria(BaseEvaluationCriteria):
162163
XPathPriority(xpath=LabXPaths.CODE_TRANSLATION_DISPLAY_NAME, priority=2),
163164
XPathPriority(xpath=LabXPaths.CODE_ORIGINAL_TEXT, priority=3),
164165
XPathPriority(xpath=LabXPaths.CODE_TRANSLATION_ORIGINAL_TEXT, priority=4),
166+
XPathPriority(xpath=LabXPaths.OBSERVATION_TEXT, priority=5),
165167
]
166168
)
167169

packages/text-to-code/tests/assets/reference_test_eicr.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</tr>
2323
</thead>
2424
<tbody>
25-
<tr>
25+
<tr ID="row_reference_1">
2626
<td ID="simple_reference_1">
2727
My reference
2828
</td>
@@ -39,6 +39,9 @@
3939
</table>
4040
</text>
4141
<observation>
42+
<text>
43+
<reference value="#row_reference_1" />
44+
</text>
4245
<code>
4346
<originalText>
4447
<reference value="#simple_reference_1" />

packages/text-to-code/tests/unit/test_eicr_processor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,16 @@ def results(self) -> list[Candidate]:
9191

9292
def test_simple_reference(self, results: list[Candidate]):
9393
expected = "My reference"
94-
assert results[0] == Candidate(value=expected, xpath=LabXPaths.CODE_ORIGINAL_TEXT)
94+
assert Candidate(value=expected, xpath=LabXPaths.CODE_ORIGINAL_TEXT) in results
9595

9696
def test_additional_text_in_original(self, results: list[Candidate]):
9797
expected = "This original text has additional text My reference Even more stuff here"
98-
assert results[1] == Candidate(
99-
value=expected, xpath=LabXPaths.CODE_TRANSLATION_ORIGINAL_TEXT
100-
)
98+
assert Candidate(value=expected, xpath=LabXPaths.CODE_TRANSLATION_ORIGINAL_TEXT) in results
10199

102100
def test_complicated_reference(self, results: list[Candidate]):
103101
expected = "A more complicated reference With extra nodes"
104-
assert results[2] == Candidate(
105-
value=expected, xpath=LabXPaths.CODE_TRANSLATION_ORIGINAL_TEXT
106-
)
102+
assert Candidate(value=expected, xpath=LabXPaths.CODE_TRANSLATION_ORIGINAL_TEXT)
103+
104+
def test_row_reference(self, results: list[Candidate]):
105+
expected = "My reference A more complicated reference With extra nodes"
106+
assert Candidate(value=expected, xpath=LabXPaths.OBSERVATION_TEXT) in results

0 commit comments

Comments
 (0)