Spaces:
Running
Running
entity-registry / packages /eval-entity-resolver /src /eval_entity_resolver /strategies /normalized.py
Download packages/eval-entity-resolver/src/eval_entity_resolver/strategies/normalized.py from evaleval/entity-registry: direct link, hf CLI and curl.
- Browser
- Download file 845 Bytes
-
https://huggingface.co/spaces/evaleval/entity-registry/resolve/main/packages/eval-entity-resolver/src/eval_entity_resolver/strategies/normalized.py
- Command line
-
hf download hf://spaces/evaleval/entity-registry/packages/eval-entity-resolver/src/eval_entity_resolver/strategies/normalized.py
-
curl -L -o normalized.py https://huggingface.co/spaces/evaleval/entity-registry/resolve/main/packages/eval-entity-resolver/src/eval_entity_resolver/strategies/normalized.py
845 Bytes
| from typing import Optional | |
| from eval_entity_resolver.normalization import normalize | |
| def normalized_match( | |
| raw_value: str, | |
| entity_type: str, | |
| alias_store, | |
| source_config: Optional[str] = None, | |
| ) -> Optional[str]: | |
| """Look the normalized input up in the normalized alias index (scoped | |
| aliases included only when ``source_config`` is given). | |
| No org-agreement guard, unlike fuzzy: the WHOLE normalized string must | |
| match, so an `org/name` raw only hits the same developer modulo | |
| case/separator (`ai21labs/x` -> `ai21-labs/x`); a different developer's org | |
| token would change the string. A bare leaf shared by two developers is | |
| deduped to one owner at seed time. | |
| """ | |
| norm = normalize(raw_value) | |
| lookup = alias_store.get_normalized_lookup(entity_type, source_config) | |
| return lookup.get(norm) | |