mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 17:55:26 -04:00
fix: topic analysis false-matches keywords as substrings (e.g. 'ai' in 'email') (#687)
* fix: match topic keywords on word boundaries, not substrings * fix: apply word-boundary matching to topic example snippets too * test: topic keywords match whole words, not substrings
This commit is contained in:
@@ -60,11 +60,11 @@ def analyze_topics(session_manager, owner: str = None) -> Dict[str, Any]:
|
||||
|
||||
for topic, keywords in TOPIC_KEYWORDS.items():
|
||||
for kw in keywords:
|
||||
if kw in content:
|
||||
if re.search(rf"\b{re.escape(kw)}\b", content):
|
||||
topic_counts[topic] += 1
|
||||
sentences = re.split(r'[.!?]', str(content_raw))
|
||||
for sentence in sentences:
|
||||
if kw in sentence.lower():
|
||||
if re.search(rf"\b{re.escape(kw)}\b", sentence.lower()):
|
||||
topic_matches[topic].append({
|
||||
"session_id": session_id,
|
||||
"session_name": session_name,
|
||||
|
||||
Reference in New Issue
Block a user