term_normalizer
TermNormalizer
Normalizes clinical term strings for high-precision matching.
Source code in src/ariadne/verbatim_mapping/term_normalizer.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
normalize_term(term)
Normalizes a clinical term string for high-precision matching.
The pipeline is:
- Convert to lowercase.
- Remove possessive "'s" at the end of words.
- Remove specific non-informative substrings (e.g., '(disorder)'). The strings are taken from the substrings_to_remove list in the config_condition_mapping.yaml file
- Remove all punctuation.
- Tokenize and lemmatize (e.g., "disorders" -> "disorder").
- Join tokens into a single string, preserving order.
This makes "liver disorders" and "Liver-Disorders (disorder)" both normalize to "liver disorder".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
term
|
str
|
The clinical term string to normalize. |
required |
Returns: The normalized term string.
Source code in src/ariadne/verbatim_mapping/term_normalizer.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
normalize_terms(terms, batch_size=1000, n_process=4)
Normalizes a list of clinical term strings in batch using spaCy's nlp.pipe for efficiency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
terms
|
List[str]
|
List of clinical term strings to normalize. |
required |
batch_size
|
int
|
Number of terms to process in each spaCy batch. |
1000
|
n_process
|
int
|
Number of worker processes for spaCy's pipe (1 disables multiprocessing). |
4
|
Returns: List of normalized term strings in the same order as the input.
Source code in src/ariadne/verbatim_mapping/term_normalizer.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |