Skip to content

Commit

Permalink
TextAnnotator: Reuse lexical index cache between calls. #573 (#574)
Browse files Browse the repository at this point in the history
Fixes #573
  • Loading branch information
cmungall authored May 20, 2023
1 parent dc21892 commit ccfb6ad
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/oaklib/interfaces/text_annotator_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,17 @@ def annotate_text(
f"{self.__class__.__name__} can't be used to match partial text"
)
else:
logging.info("Indexing ontology...")
if self.cache_directory:
index_name = f"{self.resource.scheme}-{self.resource.slug}-index.yaml"
index_path = str(Path(self.cache_directory) / index_name)
logging.info(f"Caching to {index_path}")
else:
index_path = None
self.lexical_index = create_or_load_lexical_index(
index_path, self, mapping_rule_collection=self.rule_collection
)
if not self.lexical_index:
logging.info("Indexing ontology...")
self.lexical_index = create_or_load_lexical_index(
index_path, self, mapping_rule_collection=self.rule_collection
)
logging.info("Performing naive search using lexical index")
li = self.lexical_index
text_lower = text.lower()
Expand Down

0 comments on commit ccfb6ad

Please sign in to comment.