kazu.database.in_memory_db

Classes

MetadataDatabase

Singleton of Ontology metadata database.

SynonymDatabase

Singleton of a database of synonyms.

class kazu.database.in_memory_db.MetadataDatabase[source]

Bases: object

Singleton of Ontology metadata database.

Purpose: metadata needs to be looked up in different linking processes, and this singleton allows us to load it once/reduce memory usage

__init__()[source]
Return type:

None

add_parser(name, entity_class, metadata)[source]

Add metadata to the ontology. Note, metadata is assumed to be static, and global. Calling this function will override any existing entries with associated with the keys in the metadata dict.

Parameters:
  • name (str) – name of ontology to add to

  • entity_class (str) – entity class this parser maps to

  • metadata (dict[str, dict[str, Any]]) – dict in format {idx:metadata}

Returns:

Return type:

None

get_all(name)[source]

Get all metadata associated with an ontology.

Parameters:

name (str) – name of ontology

Returns:

Return type:

dict[str, dict[str, Any]]

get_by_idx(name, idx)[source]

Get the metadata associated with an ontology and id.

Parameters:
  • name (str) – name of ontology to query

  • idx (str) – idx to query

Returns:

Return type:

dict[str, Any]

property loaded_parsers: set[str]
class kazu.database.in_memory_db.SynonymDatabase[source]

Bases: object

Singleton of a database of synonyms.

__init__()[source]
Return type:

None

add_parser(name, synonyms)[source]

Add synonyms to the database.

Parameters:
Returns:

Return type:

None

get(name, synonym)[source]

Get a set of EquivalentIdSets associated with an ontology and synonym string.

Parameters:
  • name (str) – name of ontology to query

  • synonym (str) – idx to query

Returns:

Return type:

LinkingCandidate

get_all(name)[source]

Get all synonyms associated with an ontology.

Parameters:

name (str) – name of ontology

Returns:

Return type:

dict[str, LinkingCandidate]

get_syns_for_id(name, idx, strategy_filters=None)[source]
Parameters:
Return type:

set[str]