Skip to content

Commit

Permalink
Merge pull request #37 from Sefaria/fix/finding-slugs
Browse files Browse the repository at this point in the history
feat: alternative rabbi names
  • Loading branch information
Paul-Yu-Chun-Chang authored Sep 19, 2024
2 parents 95da77c + 1a03c78 commit 7b9e977
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions VirtualHavruta/vh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,18 @@ def fetch_and_cache_topics():
topics = []
return topics

def preprocess_topic_names(extraction):
topic_names = extraction.split(",")
updated_topic_names = []
for topic in topic_names:
updated_name = topic.strip()
updated_topic_names.append(updated_name)
if updated_name.lower().startswith('rabbi'):
alt_name = updated_name[6:].strip()
if alt_name:
updated_topic_names.append(alt_name)
return updated_topic_names

def find_topic_slugs(topic_names, all_topics):
slugs = []
name_set = {name.lower() for name in topic_names}
Expand All @@ -1122,9 +1134,9 @@ def get_topic_descriptions(topic_slugs):
descriptions[slug] = topic_data['description']['en']
self.logger.info(f"MsgID={msgid}. [ONTOLOGY] Retrieved topic descriptions: {descriptions}")
return descriptions

# Process the extraction string
topic_names = extraction.split(", ")
topic_names = preprocess_topic_names(extraction)
self.logger.info(f"MsgID={msgid}. [ONTOLOGY] Extracted topic names: {topic_names}")

# Get all topics
Expand Down

0 comments on commit 7b9e977

Please sign in to comment.