Skip to content

Commit

Permalink
Removing unnecessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis-Mozart committed Dec 4, 2024
1 parent cf7c395 commit 31b7828
Showing 1 changed file with 0 additions and 78 deletions.
78 changes: 0 additions & 78 deletions semantic_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,81 +546,3 @@ def run_cache(path_kg:str, path_kge:str, cache_size:int, name_reasoner:str, evic
'strategy': eviction
}, D






# def subsumption_based_caching(func, cache_size):
# cache = {} # Dictionary to store cached results

# def store(concept, instances):
# # Check if cache limit will be exceeded
# if len(instances) + len(cache) > cache_size:
# purge(len(instances)) # Adjusted to ensure cache size limit
# # Add concept and instances to cache
# cache[concept] = instances

# def purge(needed_space):
# # Remove oldest items until there's enough space
# while len(cache) > needed_space:
# cache.pop(next(iter(cache)))

# def wrapper(*args):
# path_onto = args[1]
# onto = get_ontology(path_onto).load()

# # Synchronize the reasoner (e.g., using Pellet)
# # with onto:
# # sync_reasoner(infer_property_values=True)

# all_individuals = {a for a in onto.individuals()}
# str_expression = owl_expression_to_dl(args[0])
# owl_expression = args[0]

# # Check cache for existing results
# if str_expression in cache:
# return cache[str_expression]

# super_concepts = set()
# namespace, class_name = owl_expression.str.split('#')
# class_expression = f"{namespace.split('/')[-1]}.{class_name}"

# all_classes = [i for i in list(onto.classes())]

# for j in all_classes:
# if str(j) == class_expression:
# class_expression = j

# for D in list(cache.keys()):
# # print(owl_expression)
# # exit(0)
# if D in class_expression.ancestors(): # Check if C ⊑ D
# super_concepts.add(D)

# print(super_concepts)
# exit(0)
# # Compute instances based on subsumption
# if len(super_concepts) == 0:
# instances = all_individuals
# else:
# instances = set.intersection(
# *[wrapper(D, path_onto) for D in super_concepts]
# )

# # Filter instances by checking if each is an instance of the concept
# instance_set = set()

# for individual in instances:
# for type_entry in individual.is_a:
# type_iri = str(type_entry.iri)
# if owl_expression.str == type_iri:
# instance_set.add(individual)
# break

# # Store in cache
# store(str_expression, instance_set)
# return instance_set

# return wrapper

0 comments on commit 31b7828

Please sign in to comment.