AliasMatcher
Looks up whether predicted is an accepted answer for expected.
Inputs:
- primary_aliases - flat map {slug_a: slug_b}. Treated as a symmetric
equivalence:
slug_aandslug_bare accepted interchangeably. - secondary_aliases - {slug_a: [slug_b, slug_c, ...]} for cases where multiple slugs are valid replacements (e.g. GOOGLESHEETS_QUERY_TABLE → {BATCH_GET, LOOKUP_SPREADSHEET_ROW, VALUES_GET}). Also symmetric.
- bidirectional - set to False to disable reverse lookup (forward match only, like the original semantics).
Attributes
attributeprimary_aliasesdict[str, str]= field(default_factory=dict)attributesecondary_aliasesdict[str, list[str]]= field(default_factory=dict)attributebidirectionalbool= TrueFunctions
func__post_init__(self) -> NoneparamselfReturns
Nonefunc_build_equivalence(self) -> NoneBuild {slug: {all_equivalents}} via union-find over alias pairs.
paramselfReturns
Nonefuncfrom_files(cls, primary_path, secondary_path=None, *, bidirectional=True) -> 'AliasMatcher'paramclsparamprimary_pathstr | Pathparamsecondary_pathstr | Path | None= Noneparambidirectionalbool= TrueReturns
'AliasMatcher'funcaccepted_slugs(self, expected) -> list[str]All slugs that count as a correct prediction for expected.
paramselfparamexpectedstrReturns
list[str]funcmatches(self, expected, predicted) -> boolparamselfparamexpectedstrparampredictedstrReturns
boolfuncfound_in(self, expected, returned) -> boolTrue if any accepted slug appears in returned (a list of slugs).
paramselfparamexpectedstrparamreturnedlist[str]Returns
boolfunc__init__(self, primary_aliases=dict(), secondary_aliases=dict(), bidirectional=True) -> Noneparamselfparamprimary_aliasesdict[str, str]= dict()paramsecondary_aliasesdict[str, list[str]]= dict()parambidirectionalbool= TrueReturns
None