Open nstringham opened 2 years ago
I think in the long run option C would be better saved until after we migrate quotes to a database (unless that has already happened and I am unaware ). This issue should still be open then even if option A gets merged into main.
The quotes are now in a DB so option C is now much easier if you want to do it
User Story
As a user of the compsci bot I would like to be able to find quotes without needing to type a piece of the quote exactly.
Bug Report
Steps to Reproduce
!quote Tehranipour
!quote tehranipour
Expected Behavior
that the bot returns a quote that contains "Tehranipour"
Actual Behavior
the bot returns an error
Code Analysis
this line performs an exact case sensitive search for the query in the quote https://github.com/Nanosplitter/CompsciBot/blob/b8b60cd7b8082fee6cfaa38150f0fd7c285893f9/noncommands/quotes.py#L29
Suggested Improvements
I have 3 proposals that each fix this problem
Option A - Case Insensitive Match
replace
keywords in line
with something case insensitive such askeywords.lower() in line.lower()
Option B - Fast Fuzzy Search
replace
keywords in line
with a primitive fuzzy search algorithm/library to allow user to make typos and spelling mistakesOption C - Fuzzy Search with index
use a proper fuzzy search algorithm with a index that is generated once and used for future searches
note: that this solution works well if the quotes are stored in a database
Comparison