aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
...
| * | | | Made searching even stricter by searching from start of each wordGravatar Shirayuki Nekomata2020-02-05-11/+13
| | | | | | | | | | | | | | | | | | | | | | | | | - Added regex back to sub and split by non-alphabet. - Now use two pointers to move from words to words.
| * | | | Removed regex, implemented a stricter letter searching.Gravatar Shirayuki Nekomata2020-02-05-10/+12
| | | | |
| * | | | Increased default thresholds from just [100, 80] to [100, 90, 80, 70, 60]Gravatar Shirayuki Nekomata2020-02-05-2/+2
| | | | | | | | | | | | | | | | | | | | - Since it is returning as soon as there are suggestions found for a threshold, this will give a better reflection of what the bot thinks user is searching for.
| * | | | Removed non-alphabets from both search and tag_name when scoring.Gravatar Shirayuki Nekomata2020-02-05-2/+5
| | | | | | | | | | | | | | | | | | | | - Added a regex to remove non-alphabet ( `[^a-z]` with `re.IGNORECASE` )
| * | | | Refactored _get_suggestions following Mark's suggestions about inefficiency.Gravatar Shirayuki Nekomata2020-02-04-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Matching scores will be calculated once now and stored in the dict `scores`. - Allow `_get_suggestions()` to go through a list of score threshold and return the first list of matching tags that's not empty and above the threshold. This avoid calling the function multiple time like before ( `self._get_suggestions(tag_name, 100) or self._get_suggestions(tag_name, 80)` for example, is calling this function twice, and is inefficient ) - Deleted commented line. - Added `typing` module for more typehints.
| * | | | Fixed _last_fetch not being updated after each api call.Gravatar Shirayuki Nekomata2020-02-04-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Changed type of `self._last_fetch` to `float` and give it the initial value of `0.0` instead of `None` - Assigned `time.time()` to `time_now` to avoid calling this function twice. - Added `self._last_fetch = time_now` after calling the api call.
| * | | | Merge branch 'master' into fuzzy-tag-searchGravatar Joseph2020-02-02-2959/+6887
| |\ \ \ \
| * | | | | Make it easier for user to search for tagsGravatar Shirayuki Nekomata2019-10-18-9/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #### Closes #231 Applying the algorithm for `Needles and Haystack` to find and match tag in tags, for example: ![Example](https://cdn.discordapp.com/attachments/634243438459486219/634592981915140107/unknown.png) This only applies to searching tag_name with more than 3 in length, and at least 80% of its letters are found, from left to right. There are 3 levels of checking, stop at first found: - Check if exact name ( case insensitive ) O(1) getting from a dictionary Dict[str, Tag] - Check for all tags that has 100% matching via algorithm - Check for all tags that has >= 80% matching If there are more than one hit, it will be shown as suggestions: ![Suggestions](https://cdn.discordapp.com/attachments/634243438459486219/634595369531211778/unknown.png) In order to avoid api being called multiple times, I've implemented a cache to only refresh itself when the is a gap of more than 5 minutes from the last api call to get all tags. Editing / Adding / Deleting tags will also modify the cache directly. ##### What about other solution like fuzzywuzzy? fuzzywuzzy was considered for using, but from testing, it was giving much lower scores than expected: Code used to test: ```py from fuzzywuzzy import fuzz def _fuzzy_search(search: str, target: str) -> bool: found = 0 index = 0 _search = search.lower().replace(' ', '') _target = target.lower().replace(' ', '') for letter in _search: index = _target.find(letter, index) if index == -1: break found += index > 0 # return found / len(_search) * 100 return ( found / len(_search) * 100, fuzz.ratio(search, target), fuzz.partial_ratio(search, target) ) tests = ( 'this-is-gonna-be-fun', 'this-too-will-be-fun' ) for test in tests: print(test, '->', _fuzzy_search('this too fun', test)) ``` Result from test: ```py this-is-gonna-be-fun -> (30.0, 50, 50) this-too-will-be-fun -> (90.0, 62, 58) ```
| | | * | | Fix linting errorGravatar kosayoda2019-10-28-2/+2
| | | | | |
| | | * | | Apply suggestions from code review Gravatar Kieran Siek2019-10-28-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix incorrect docstring and comment Co-Authored-By: Mark <[email protected]>
| | | * | | Add delete emoji to paginationGravatar kosayoda2019-10-28-10/+21
| | | | | |
| | | * | | Revert "Remove dev-test limit for filtering debugging"Gravatar kosayoda2019-10-28-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 56696b3b1858ad27dc7f3dce2898c7a6eb151f43.
| | | * | | Remove dev-test limit for filtering debuggingGravatar kosayoda2019-10-27-2/+2
| | | | | |
| | | * | | Differentiate clear and delete emoji in help cogGravatar kosayoda2019-10-27-10/+13
| | | | | |
| | | * | | Use trashcan emoji for message deletionGravatar kosayoda2019-10-27-1/+9
| | | | | |
| | | | * | Add unit test for newlines antispam ruleGravatar kwzrd2020-02-04-0/+105
| | | | | |
| | | | * | Add unit test for duplicates antispam ruleGravatar kwzrd2020-02-04-0/+66
| | | | | |
| | | | * | Merge branch 'master' into unittest-antispam-rulesGravatar Joseph2020-02-02-1/+10
| | | | |\ \ | | | |_|/ / | | |/| | |
| | | | * | Make RuleTest use ABCMetaGravatar kwzrd2020-02-02-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will prevent child classes to be instantiated unless they implement all abstract methods, leading to a more descriptive error message.
| | | | * | Adjust existing tests to inherit from RuleTest ABCGravatar kwzrd2020-02-02-294/+157
| | | | | |
| | | | * | Implement RuleTest ABCGravatar kwzrd2020-02-02-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will serve as an ABC for tests for individual rules. The base class provides runners for allowed and disallowed cases, and the children classes then only provide the cases and implementations of helper methods specific to each rule.
| | | | * | Adjust multi-line docstrings to prevailing styleGravatar kwzrd2020-01-31-3/+6
| | | | | |
| | | | * | Refactor msg helper function name to make_msgGravatar kwzrd2020-01-26-25/+25
| | | | | | | | | | | | | | | | | | | | | | | | The name msg is less descriptive and creates a needless name conflict in local gen exp.
| | | | * | Fix incorrect config key in attachments antispam ruleGravatar kwzrd2020-01-26-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The rule was incorrectly printing out the maximum amount of allowed attachments instead of the configured interval. This commit also adjusts the rule's unit test case.
| | | | * | Add unit test case for role mentions antispam ruleGravatar kwzrd2020-01-26-0/+66
| | | | | |
| | | | * | Add unit test case for discord emojis antispam ruleGravatar kwzrd2020-01-26-0/+68
| | | | | |
| | | | * | Add unit test case for chars antispam ruleGravatar kwzrd2020-01-26-0/+75
| | | | | |
| | | | * | Add unit test case for burst shared antispam ruleGravatar kwzrd2020-01-26-0/+65
| | | | | |
| | | | * | Add unit test case for burst antispam ruleGravatar kwzrd2020-01-26-0/+69
| | | | | |
| | | | | * Remove the space that makes the test failGravatar Deniz2020-02-21-1/+1
| | | | | |
| | | | | * Use the code provided by sco1 to fix the checks failing.Gravatar Deniz2020-02-21-5/+10
| | | | | |
| | | | | * Add thousand separators to Members count, closes #744Gravatar Deniz2020-02-13-4/+4
| | | | | |
| | | | | * Update the tests accordingly to reflect the new changesGravatar Deniz2020-02-13-3/+3
| | | | | |
| | | | | * Use collections.Counter properly. Use the ChannelType enum instead of the ↵Gravatar Deniz2020-02-12-12/+6
| | | | | | | | | | | | | | | | | | | | | | | | __class__ attribute, and re-add the None check for !user roles.
| | | | | * Use the enum itself instead of its string valueGravatar Deniz2020-02-08-6/+6
| | | | | |
| | | | | * Fix some of the testing for information.py; I think this should be it. ↵Gravatar Deniz2020-02-06-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | (hopefully).
| | | | | * Change if statement to elif; if the first if statement returns true, the ↵Gravatar Deniz2020-02-06-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | second cannot be true making it unneccesary to check
| | | | | * Fix up imports a bit; there's no need to import all of discord and typing ↵Gravatar Deniz2020-02-06-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | for just 1 or 2 uses (e.g. Union, and Message).
| | | | | * Instead of sending a message everytime a role can't be converted, append it ↵Gravatar Deniz2020-02-06-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | to a list, and then send them it at once (less spammy)
| | | | | * Update tests to reflect status changesGravatar Deniz2020-02-06-4/+4
| | | | | |
| | | | | * Refactor how channels and statuses are counted; using Counter() - way cleaner.Gravatar Deniz2020-02-06-35/+17
| | | | | |
| | | | | * Remove some a lot of unneccesary newlines that arguably make it harder to readGravatar Deniz2020-02-06-9/+2
| | | | | |
| | | | | * Roles cannot return None because everyone has the Developer role by default, ↵Gravatar Deniz2020-02-06-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | and non-verified users cannot use this command.
| | | | | * No longer check if every role is @everyone; just skip the first element in ↵Gravatar Deniz2020-02-06-3/+2
| |_|_|_|/ |/| | | | | | | | | | | | | | the list
* | | | | Merge pull request #737 from python-discord/remove-prometheusGravatar Mark2020-02-05-272/+128
|\ \ \ \ \ | | | | | | | | | | | | Remove prometheus related code
| * \ \ \ \ Merge branch 'master' into remove-prometheusGravatar S. Co12020-02-05-41/+71
| |\ \ \ \ \ | |/ / / / / |/| | | | |
* | | | | | Merge pull request #739 from python-discord/resources-moveGravatar Leon Sandøy2020-02-05-2/+2
|\ \ \ \ \ \ | | | | | | | | | | | | | | Move tools and questions guide to under resources
| * | | | | | Add missing slash to asking good questions url.Gravatar scragly2020-02-06-1/+1
| | | | | | |
| * | | | | | Move tools and questions guide to under resourcesGravatar scragly2020-02-05-2/+2
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | After the wiki pages adjustment to the resources page, these two urls are needing to be updated to point to the new correct locations for each page. Tools will be under resources, and Asking Good Questions is a guide, so will be under Guides.
* | | | | | Relay attachments to log channel before filters delete message (#630)Gravatar scragly2020-02-04-39/+69
|\ \ \ \ \ \ | |_|_|/ / / |/| | | | | Relay attachments to log channel before filters delete message