mirror of https://gitlab.com/bashrc2/epicyon
Fix test
parent
33ecd05abb
commit
8485371197
|
@ -165,6 +165,9 @@ def guessHashtagCategory(tagName: str, hashtagCategories: {}) -> 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:
|
||||||
|
return ''
|
||||||
|
|
||||||
categoryMatched = ''
|
categoryMatched = ''
|
||||||
tagMatchedLen = 0
|
tagMatchedLen = 0
|
||||||
|
|
||||||
|
@ -185,5 +188,5 @@ def guessHashtagCategory(tagName: str, hashtagCategories: {}) -> str:
|
||||||
if len(hashtag) > tagMatchedLen:
|
if len(hashtag) > tagMatchedLen:
|
||||||
categoryMatched = categoryStr
|
categoryMatched = categoryStr
|
||||||
if not categoryMatched:
|
if not categoryMatched:
|
||||||
return
|
return ''
|
||||||
return categoryMatched
|
return categoryMatched
|
||||||
|
|
4
tests.py
4
tests.py
|
@ -2843,12 +2843,12 @@ def _testGuessHashtagCategory() -> None:
|
||||||
print('testGuessHashtagCategory')
|
print('testGuessHashtagCategory')
|
||||||
hashtagCategories = {
|
hashtagCategories = {
|
||||||
"foo": ["swan", "goose"],
|
"foo": ["swan", "goose"],
|
||||||
"bar": ["cat", "mouse"]
|
"bar": ["cats", "mouse"]
|
||||||
}
|
}
|
||||||
guess = guessHashtagCategory("unspecifiedgoose", hashtagCategories)
|
guess = guessHashtagCategory("unspecifiedgoose", hashtagCategories)
|
||||||
assert guess == "foo"
|
assert guess == "foo"
|
||||||
|
|
||||||
guess = guessHashtagCategory("catpic", hashtagCategories)
|
guess = guessHashtagCategory("mastocats", hashtagCategories)
|
||||||
assert guess == "bar"
|
assert guess == "bar"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue