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 llm_attribute_extractor.py and hierarchy_attribute_evaluator.py.
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 | |
ReferenceSearchResult
Bases: NamedTuple
Return type for reference search and find_similar_reference_terms.
Source code in src/ariadne/hierarchy/types.py
43 44 45 46 47 | |
SearchBatchResult
Bases: NamedTuple
Return type for search_batch.
Source code in src/ariadne/hierarchy/types.py
36 37 38 39 40 | |
SearchResult
Bases: NamedTuple
Return type for attribute search and _retrieve_candidates.
Source code in src/ariadne/hierarchy/types.py
29 30 31 32 33 | |
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
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 119 | |
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
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
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
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |