role_grouper
Assign extracted SNOMED CT attributes to role groups.
The grouping combines:
- LLM-proposed groups (
role_groupsin the selection output) for the clusters listed inhierarchy.mrcm.grouping.llm_grouped_clusters; interprets_interpretationpairs (each pair is one group);- deterministic rules for everything else: self-grouped attributes get one group per value; for a cluster, one group when every attribute has a single value, one group per value when one attribute has several values (single values are repeated in every group), and a positional fallback when several attributes have several values (ambiguous — flagged).
Output format (result["role_groups"])::
[{"group": 1, "members": [{"attribute": "finding_site", "concept_id": ..., "concept_name": ...,
"concept_code": ...}, ...]}, ...]
group 0 holds attributes the MRCM marks as ungrouped for the term's domain.
attribute_keys(attributes)
Attribute keys with at least one value (interprets_interpretation expanded).
Source code in src/ariadne/hierarchy/role_grouper.py
81 82 83 84 85 86 87 88 89 90 91 | |
flatten_role_groups(llm_role_groups)
Collapse LLM role_groups ([{attribute_key: concept | [concepts]}]) to flat attributes.
Source code in src/ariadne/hierarchy/role_grouper.py
94 95 96 97 98 99 100 101 | |
group_attributes(attributes, settings, llm_role_groups=None, rules=None, domain=None)
Assign the selected attributes of one term to role groups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attributes
|
dict | None
|
|
required |
settings
|
MrcmSettings
|
|
required |
llm_role_groups
|
list[dict] | None
|
Normalized LLM role groups |
None
|
rules
|
Any
|
Optional :class: |
None
|
domain
|
str | None
|
MRCM domain name of the term. |
None
|
Returns:
| Type | Description |
|---|---|
GroupingResult
|
|
Source code in src/ariadne/hierarchy/role_grouper.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
group_result(result, settings, rules=None)
Set role_groups, grouping_method and, when rules is given, mrcm_domain on a
pipeline result (in place).
Source code in src/ariadne/hierarchy/role_grouper.py
254 255 256 257 258 259 260 261 262 263 | |
regroup_result(result, settings, rules=None)
Return a copy of a pipeline result with role groups (re)computed by :func:group_result.
Results with an error key are returned unchanged.
Source code in src/ariadne/hierarchy/role_grouper.py
266 267 268 269 270 271 272 273 274 275 | |
regroup_results(results, settings, rules=None)
Apply :func:regroup_result to cached pipeline results (no LLM calls).
Source code in src/ariadne/hierarchy/role_grouper.py
278 279 280 | |