From f6d11bdc4e196e812b2d13fbf3da5d2c1145881c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 10 Jan 2024 14:04:53 +0000 Subject: [PATCH] Check for exact matches --- categories.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/categories.py b/categories.py index 7757833b8..e2159f557 100644 --- a/categories.py +++ b/categories.py @@ -272,9 +272,17 @@ def guess_hashtag_category(tag_name: str, hashtag_categories: {}, category_matched = '' tag_matched_len = 0 + finished = False for category_str, hashtag_list in hashtag_categories.items(): + if finished: + break for hashtag in hashtag_list: + if hashtag == tag_name: + # exact match + category_matched = category_str + finished = True + break if len(hashtag) < min_tag_length: # avoid matching very small strings which often # lead to spurious categories