minimum hashtag length for guessing

merge-requests/30/head
Bob Mottram 2024-01-10 13:41:59 +00:00
parent 0ae87b671c
commit a088d4dde2
1 changed files with 5 additions and 5 deletions

View File

@ -262,11 +262,11 @@ def set_hashtag_category(base_dir: str, hashtag: str, category: str,
return False return False
def guess_hashtag_category(tagName: str, hashtag_categories: {}) -> str: def guess_hashtag_category(tag_name: str, hashtag_categories: {}) -> str:
"""Tries to guess a category for the given hashtag. """Tries to guess a category for the given hashtag.
This works by trying to find the longest similar hashtag This works by trying to find the longest similar hashtag
""" """
if len(tagName) < 4: if len(tag_name) < 6:
return '' return ''
category_matched = '' category_matched = ''
@ -274,12 +274,12 @@ def guess_hashtag_category(tagName: str, hashtag_categories: {}) -> str:
for category_str, hashtag_list in hashtag_categories.items(): for category_str, hashtag_list in hashtag_categories.items():
for hashtag in hashtag_list: for hashtag in hashtag_list:
if len(hashtag) < 4: if len(hashtag) < 6:
# avoid matching very small strings which often # avoid matching very small strings which often
# lead to spurious categories # lead to spurious categories
continue continue
if hashtag not in tagName: if hashtag not in tag_name:
if tagName not in hashtag: if tag_name not in hashtag:
continue continue
if not category_matched: if not category_matched:
tag_matched_len = len(hashtag) tag_matched_len = len(hashtag)