aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2021-08-29 19:04:25 +0200
committerGravatar Numerlor <[email protected]>2021-08-29 19:04:25 +0200
commit9c740dca0f7685a0e0e02b7a1de5557f900b84fc (patch)
treec14ce12c996bfff31ba7e05ec5b7ad2cda4b4b4f
parentFix punctuation (diff)
Simplify group_score definition
Co-authored-by: Bluenix <[email protected]>
-rw-r--r--bot/exts/info/tags.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/bot/exts/info/tags.py b/bot/exts/info/tags.py
index cd02f1768..b7c361c78 100644
--- a/bot/exts/info/tags.py
+++ b/bot/exts/info/tags.py
@@ -43,19 +43,14 @@ class TagIdentifier(NamedTuple):
def get_fuzzy_score(self, fuzz_tag_identifier: TagIdentifier) -> float:
"""Get fuzzy score, using `fuzz_tag_identifier` as the identifier to fuzzy match with."""
- if self.group is None:
- if fuzz_tag_identifier.group is None:
- # We're only fuzzy matching the name
- group_score = 1
- else:
- # Ignore tags without groups if the identifier contains a group
- return .0
+ if (self.group is None) != (fuzz_tag_identifier.group is None):
+ # Ignore tags without groups if the identifier has a group and vice versa
+ return .0
+ if self.group == fuzz_tag_identifier.group:
+ # Completely identical, or both None
+ group_score = 1
else:
- if fuzz_tag_identifier.group is None:
- # Ignore tags with groups if the identifier does not have a group
- return .0
- else:
- group_score = _fuzzy_search(fuzz_tag_identifier.group, self.group)
+ group_score = _fuzzy_search(fuzz_tag_identifier.group, self.group)
fuzzy_score = group_score * _fuzzy_search(fuzz_tag_identifier.name, self.name) * 100
if fuzzy_score: