types
Shared types and helpers for the SNOMED CT hierarchy pipeline.
NamedTuple result types provide self-documenting returns while remaining
backward-compatible with existing a, b = func() unpacking.
interprets ↔ interpretation helpers centralise the paired-attribute logic that was previously duplicated across pipeline.py and evaluator.py.
ExtractionResult
Bases: NamedTuple
Return type for :func:~ariadne.hierarchy.pipeline.extract_components.
Source code in src/ariadne/hierarchy/types.py
29 30 31 32 33 | |
LlmResult
Bases: NamedTuple
Return type for :func:~ariadne.hierarchy.pipeline.call_llm.
Source code in src/ariadne/hierarchy/types.py
22 23 24 25 26 | |
ReferenceRetrievalResult
Bases: NamedTuple
Return type for _retrieve_reference_examples.
Source code in src/ariadne/hierarchy/types.py
57 58 59 60 61 62 | |
ReferenceSearchResult
Bases: NamedTuple
Return type for reference search and find_similar_reference_terms.
Source code in src/ariadne/hierarchy/types.py
50 51 52 53 54 | |
SearchBatchResult
Bases: NamedTuple
Return type for search_batch.
Source code in src/ariadne/hierarchy/types.py
43 44 45 46 47 | |
SearchResult
Bases: NamedTuple
Return type for attribute search and _retrieve_candidates.
Source code in src/ariadne/hierarchy/types.py
36 37 38 39 40 | |
merge_interprets_keys(interprets_list, interpretation_list, *, verbose=False)
Merge separate interprets / interpretation lists into paired dicts.
Handles the backward-compatibility case where the LLM returns separate top-level
keys instead of the expected interprets_interpretation list of pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
interprets_list
|
list | None
|
Values for the interprets side (may be a single value). |
required |
interpretation_list
|
list | None
|
Values for the interpretation side. |
required |
verbose
|
bool
|
Log warnings for dropped orphans. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict] | None
|
List of |
Source code in src/ariadne/hierarchy/types.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
split_interprets_pairs(pairs)
Split interprets_interpretation pairs into (attr_key, value) items.
Works for both mention-string pairs (pipeline retrieval) and concept-dict pairs (evaluator prediction rows).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pairs
|
list
|
List of dicts with optional |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[str, Any]]
|
List of |
Source code in src/ariadne/hierarchy/types.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
validate_interprets_pairs(pairs, *, verbose=False)
Drop interprets_interpretation pairs missing either side.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pairs
|
list
|
List of pair dicts to validate. |
required |
verbose
|
bool
|
Log warnings for dropped incomplete pairs. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict] | None
|
List of valid pairs, or |
Source code in src/ariadne/hierarchy/types.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |