|
3 | 3 |
|
4 | 4 | import pytest |
5 | 5 | import spacy |
6 | | -from deep_reference_parser.prodigy.numbered_reference_annotator import NumberedReferenceAnnotator |
| 6 | +from deep_reference_parser.prodigy.numbered_reference_annotator import ( |
| 7 | + NumberedReferenceAnnotator, |
| 8 | +) |
| 9 | + |
7 | 10 |
|
8 | 11 | @pytest.fixture(scope="function") |
9 | 12 | def nra(): |
@@ -111,20 +114,30 @@ def test_numbered_reference_splitter(nra): |
111 | 114 | {"text": "\n", "start": 470, "end": 471, "id": 92}, |
112 | 115 | {"text": "3", "start": 471, "end": 472, "id": 92}, |
113 | 116 | {"text": ".", "start": 472, "end": 473, "id": 92}, |
114 | | - ] |
| 117 | + ], |
115 | 118 | } |
116 | 119 |
|
117 | 120 | docs = list(nra.run([numbered_reference])) |
118 | 121 | text = docs[0]["text"] |
119 | 122 | spans = docs[0]["spans"] |
120 | | - ref_1 = text[spans[0]["start"]:spans[0]["end"]] |
121 | | - ref_2 = text[spans[1]["start"]:spans[1]["end"]] |
122 | | - ref_3 = text[spans[2]["start"]:spans[2]["end"]] |
| 123 | + ref_1 = text[spans[0]["start"] : spans[0]["end"]] |
| 124 | + ref_2 = text[spans[1]["start"] : spans[1]["end"]] |
| 125 | + ref_3 = text[spans[2]["start"] : spans[2]["end"]] |
123 | 126 |
|
124 | 127 | assert len(spans) == 3 |
125 | | - assert ref_1 == "Global update on the health sector response to HIV, 2014. Geneva: World Health Organization; \n 2014:168." |
126 | | - assert ref_2.strip() == "WHO, UNICEF, UNAIDS. Global update on HIV treatment 2013: results, impact and \n opportunities. Geneva: World Health Organization; 2013:126." |
127 | | - assert ref_3.strip() == "Consolidated guidelines on the use of antiretroviral drugs for treating and preventing HIV infection: \n recommendations for a public health approach. Geneva: World Health Organization; 2013:272." |
| 128 | + assert ( |
| 129 | + ref_1 |
| 130 | + == "Global update on the health sector response to HIV, 2014. Geneva: World Health Organization; \n 2014:168." |
| 131 | + ) |
| 132 | + assert ( |
| 133 | + ref_2.strip() |
| 134 | + == "WHO, UNICEF, UNAIDS. Global update on HIV treatment 2013: results, impact and \n opportunities. Geneva: World Health Organization; 2013:126." |
| 135 | + ) |
| 136 | + assert ( |
| 137 | + ref_3.strip() |
| 138 | + == "Consolidated guidelines on the use of antiretroviral drugs for treating and preventing HIV infection: \n recommendations for a public health approach. Geneva: World Health Organization; 2013:272." |
| 139 | + ) |
| 140 | + |
128 | 141 |
|
129 | 142 | def test_numbered_reference_splitter_line_endings(nra): |
130 | 143 | """ |
@@ -196,15 +209,21 @@ def test_numbered_reference_splitter_line_endings(nra): |
196 | 209 | {"text": "\n\n", "start": 261, "end": 263, "id": 58}, |
197 | 210 | {"text": "3", "start": 262, "end": 264, "id": 59}, |
198 | 211 | {"text": ".", "start": 263, "end": 265, "id": 60}, |
199 | | - ] |
| 212 | + ], |
200 | 213 | } |
201 | 214 |
|
202 | 215 | docs = list(nra.run([numbered_reference])) |
203 | 216 | text = docs[0]["text"] |
204 | 217 | spans = docs[0]["spans"] |
205 | | - ref_1 = text[spans[0]["start"]:spans[0]["end"]] |
206 | | - ref_2 = text[spans[1]["start"]:spans[1]["end"]] |
| 218 | + ref_1 = text[spans[0]["start"] : spans[0]["end"]] |
| 219 | + ref_2 = text[spans[1]["start"] : spans[1]["end"]] |
207 | 220 |
|
208 | 221 | assert len(spans) == 2 |
209 | | - assert ref_1.strip() == "Global update on the health sector response to HIV, 2014. Geneva: World Health Organization; \n 2014:168." |
210 | | - assert ref_2.strip() == "WHO, UNICEF, UNAIDS. Global update on HIV treatment 2013: results, impact and \n opportunities. Geneva: World Health Organization; 2013:126" |
| 222 | + assert ( |
| 223 | + ref_1.strip() |
| 224 | + == "Global update on the health sector response to HIV, 2014. Geneva: World Health Organization; \n 2014:168." |
| 225 | + ) |
| 226 | + assert ( |
| 227 | + ref_2.strip() |
| 228 | + == "WHO, UNICEF, UNAIDS. Global update on HIV treatment 2013: results, impact and \n opportunities. Geneva: World Health Organization; 2013:126" |
| 229 | + ) |
0 commit comments