david-swift / Memorize

Study flashcards in a native GNOME app
https://flathub.org/apps/io.github.david_swift.Flashcards
GNU General Public License v3.0
87 stars 9 forks source link

Search function returns incorrect output #48

Closed rene-coty closed 3 months ago

rene-coty commented 3 months ago

Describe the bug

Searching for a flashcard in a set can give erroneous output, with flashcards that don't contain the requested input at all. This happens especially when the set has a lot of flashcards, and it can make the search function almost useless

To Reproduce

  1. Open a big flashcard set
  2. Search for anything
  3. See output

Expected behavior

The displayed search result(s) should only be directly related to the input, ie. only contain the searched string

Additional context

You can test my problem with this .csv file, that I regularly use (~ 130 flashcards with a lot of text)

david-swift commented 3 months ago

The search function is implemented here:

https://github.com/david-swift/Memorize/blob/0e6cba49ddde128c9fa0b9e7894735113d89e6a3/Sources/Model/Extensions/String.swift#L11

It currently checks whether there is each letter in the string in the right order, and hides a flashcard if this is not the case. So if I search for "hello", both "hello" and "hysterical elephants like loud oboes" will be visible while "world" won't.

In order to make this feature more useful, we could:

I prefer the first option. What do you think, do you have another suggestion?

rene-coty commented 3 months ago

I think hiding results that might be relevant is indeed a bad idea, so my preference also goes to the first option. I can't really represent myself how this separate view would look like though…

david-swift commented 3 months ago

I think it could look similar to the one used in settings dialogs:

Screenshot from 2024-05-20 15-33-21

But with question - answer instead of label - path.

rene-coty commented 3 months ago

That would be neat indeed!

david-swift commented 3 months ago

I implemented the new search view and a new algorithm based on FuzzyFind in 1efab42.

Screenshot from 2024-06-02 15-18-56