diff options
| author | 2021-09-06 01:02:54 +0200 | |
|---|---|---|
| committer | 2021-09-06 01:02:54 +0200 | |
| commit | ba2a74ac18f9e40fad917d51ffa2238a340416c0 (patch) | |
| tree | 97cc203dd8a5e9591081eea48b53083b5f51f31b | |
| parent | Simplify group_score definition (diff) | |
simplify fuzzy suggestion func
Co-authored-by: Bluenix <[email protected]>
| -rw-r--r-- | bot/exts/info/tags.py | 23 | 
1 files changed, 9 insertions, 14 deletions
| diff --git a/bot/exts/info/tags.py b/bot/exts/info/tags.py index b7c361c78..909831bc7 100644 --- a/bot/exts/info/tags.py +++ b/bot/exts/info/tags.py @@ -162,21 +162,16 @@ class Tags(Cog):      def get_fuzzy_matches(self, tag_identifier: TagIdentifier) -> list[tuple[TagIdentifier, Tag]]:          """Get tags with identifiers similar to `tag_identifier`.""" -        if tag_identifier.group is None: -            if len(tag_identifier.name) < 3: -                return [] -            else: -                return self._get_suggestions(tag_identifier) -        else: -            if len(tag_identifier.group) < 3: -                suggestions = [] -            else: -                # Try fuzzy matching with only a name first -                suggestions = self._get_suggestions(TagIdentifier(None, tag_identifier.group)) +        suggestions = [] + +        if tag_identifier.group is not None and len(tag_identifier.group) >= 3: +            # Try fuzzy matching with only a name first +            suggestions += self._get_suggestions(TagIdentifier(None, tag_identifier.group)) + +        if len(tag_identifier.name) >= 3: +            suggestions += self._get_suggestions(tag_identifier) -            if len(tag_identifier.name) >= 3: -                suggestions += self._get_suggestions(tag_identifier) -            return suggestions +        return suggestions      def _get_tags_via_content(              self, | 
