From 9c740dca0f7685a0e0e02b7a1de5557f900b84fc Mon Sep 17 00:00:00 2001 From: Numerlor <25886452+Numerlor@users.noreply.github.com> Date: Sun, 29 Aug 2021 19:04:25 +0200 Subject: Simplify group_score definition Co-authored-by: Bluenix --- bot/exts/info/tags.py | 19 +++++++------------ 1 file 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: -- cgit v1.2.3