ontolearn.semantic_caching

python examples/retrieval_eval.py

Classes

CacheWithEviction

Functions

concept_generator(path_kg)

get_shuffled_concepts(path_kg, data_name)

Shuffle the generated concept and save it in a folder for reproducibility

concept_retrieval(→ Set[str])

semantic_caching_size(func, cache_size, ...)

This function implements the semantic caching algorithm for ALC concepts as presented in the paper

non_semantic_caching_size(func, cache_size)

This function implements a caching algorithm for ALC concepts without semantics.

retrieve(→ Tuple[Set[str], Set[str]])

Retrieve instances with neural reasoner

retrieve_other_reasoner(expression, path_kg[, ...])

Retrieve instances with symbolic reasoners

run_semantic_cache(path_kg, path_kge, cache_size, ...)

Return cache performnace with semantics

run_non_semantic_cache(path_kg, path_kge, cache_size, ...)

Return cache performnace without any semantics

Module Contents

ontolearn.semantic_caching.concept_generator(path_kg)[source]
ontolearn.semantic_caching.get_shuffled_concepts(path_kg, data_name)[source]

Shuffle the generated concept and save it in a folder for reproducibility

ontolearn.semantic_caching.concept_retrieval(retriever_func, c) Set[str][source]
class ontolearn.semantic_caching.CacheWithEviction(cache_size, strategy='LIFO', random_seed=10)[source]
cache
access_times
cache_size
strategy = 'LIFO'
random_seed = 10
initialized = False
get(key)[source]

Retrieve an item from the cache. Updates access time for LRU/MRU.

put(key, value)[source]

Add an item to the cache. Evicts an entry if the cache is full.

initialize_cache(func, path_onto, third, All_individuals, handle_restriction_func, concepts)[source]

Initialize the cache with precomputed results for OWLClass and Existential concepts. :param ontology: The loaded ontology. :param func: Function to retrieve individuals for a given expression. :param concepts: List of OWL concepts to precompute and store instances for.

get_all_items()[source]
is_full()[source]

Check if the cache is full.

ontolearn.semantic_caching.semantic_caching_size(func, cache_size, eviction_strategy, random_seed, cache_type, concepts)[source]

This function implements the semantic caching algorithm for ALC concepts as presented in the paper

ontolearn.semantic_caching.non_semantic_caching_size(func, cache_size)[source]

This function implements a caching algorithm for ALC concepts without semantics.

ontolearn.semantic_caching.retrieve(expression: str, path_kg: str, path_kge_model: str) Tuple[Set[str], Set[str]][source]

Retrieve instances with neural reasoner

ontolearn.semantic_caching.retrieve_other_reasoner(expression, path_kg, name_reasoner='HermiT')[source]

Retrieve instances with symbolic reasoners

ontolearn.semantic_caching.run_semantic_cache(path_kg: str, path_kge: str, cache_size: int, name_reasoner: str, eviction: str, random_seed: int, cache_type: str, shuffle_concepts: str)[source]

Return cache performnace with semantics

ontolearn.semantic_caching.run_non_semantic_cache(path_kg: str, path_kge: str, cache_size: int, name_reasoner: str, shuffle_concepts: str)[source]

Return cache performnace without any semantics