|
a |
|
b/docs/utilities/tests/examples.md |
|
|
1 |
# Creating Examples |
|
|
2 |
|
|
|
3 |
Testing a NER/qualifier pipeline can be a hassle. We created a utility to simplify that process. |
|
|
4 |
|
|
|
5 |
Using the [`parse_example`][edsnlp.utils.examples.parse_example] method, you can define a full example in a human-readable way: |
|
|
6 |
|
|
|
7 |
```python |
|
|
8 |
from edsnlp.utils.examples import parse_example |
|
|
9 |
|
|
|
10 |
example = "Absence d'<ent negated=true>image osseuse d'allure évolutive</ent>." |
|
|
11 |
|
|
|
12 |
text, entities = parse_example(example) |
|
|
13 |
|
|
|
14 |
text |
|
|
15 |
# Out: "Absence d'image osseuse d'allure évolutive." |
|
|
16 |
|
|
|
17 |
entities |
|
|
18 |
# Out: [Entity(start_char=10, end_char=42, modifiers=[Modifier(key='negated', value=True)])] |
|
|
19 |
``` |
|
|
20 |
|
|
|
21 |
Entities are defined using the `<ent>` tag. You can encode complexe information by adding keys into the tag (see example above). The `parse_example` method strips the text of the tags, and outputs a list of `Entity` objects that contain: |
|
|
22 |
|
|
|
23 |
- the character indices of the entity ; |
|
|
24 |
- custom user-defined "modifiers". |
|
|
25 |
|
|
|
26 |
See the [dedicated reference page][edsnlp.utils.examples.parse_example] for more information. |