make_grounder
- make_grounder(grounder_hint: Iterable[LiteralMapping] | Grounder[R], *, implementation: Literal['gilda'] | None = None, progress: bool = False, **kwargs: Any) Grounder[R][source]
- make_grounder(grounder_hint: str | Path | gilda.Grounder, *, implementation: Literal['gilda'] | None = None, progress: bool = False, **kwargs: Any) Grounder[NamableReference]
Get a grounder from literal mappings.
- Parameters:
grounder_hint –
An object that can be coerced into a SSSLM-backed grounder. Can be one of the following:
A URL or file path
An iterable of literal mappings
A pre-instantiated grounder or gilda grounder
implementation – If literal mappings are passed, what kind of grounder to use
progress – If True, show a progress bar when loading literal mappings
kwargs – If literal mappings are passed, keyword arguments passed to the construction of the grounder
- Returns:
A SSSLM standard grounder
A grounder can be constructed from a URL. In the following example, a pre-processed lexical index of anatomical terms from UBERON, BTO, MeSH, and other resources is loaded from the
biolexicaproject.import ssslm url = f"https://github.com/biopragmatics/biolexica/raw/main/lexica/anatomy/anatomy.ssslm.tsv.gz" grounder = ssslm.make_grounder(url) match = grounder.get_best_match("purkinje cell")
A grounder can be constructed from literal mappings that are already stored in a Python object. This example uses the same lexical index as above, first loading it by URL.
import ssslm url = f"https://github.com/biopragmatics/biolexica/raw/main/lexica/anatomy/anatomy.ssslm.tsv.gz" literal_mappings = ssslm.read_literal_mappings(url) grounder = ssslm.make_grounder(literal_mappings) match = grounder.get_best_match("purkinje cell")
A grounder can be constructed from a pre-existing
gilda.Grounderobject. As SSSLM is extended, this will incorporate other grounder interfaces.import ssslm from gilda.api import grounder as gilda_default_grounder grounder = ssslm.make_grounder(gilda_default_grounder) match = grounder.get_best_match("purkinje cell")