jProgr / TokiPonaDictionary

A Toki Pona - English dictionary with search function
https://jprogr.github.io/TokiPonaDictionary/
Other
48 stars 11 forks source link

Differentiate between whole and partial matches #13

Closed mitaa closed 3 years ago

mitaa commented 3 years ago

toki!

Thanks for creating this, I've been using it quite often and I've noticed this issue with the search results and later found the discussion in #9.

I've tried implementing your idea to clone, pin, and highlight exact whole-word-matches at the top. (I also have a branch where I didn't clone the nodes and instead moved them to the top)

What I haven't addressed (yet?) is your concern that too many exact matches could bury desired partial matches.

I'm not very experienced with javascript and html/css but I hope this is at least in part helpful. (especially the CSS was a pain to get good results)

Screenshot_2021-01-21 Toki Pona Dictionary

jProgr commented 3 years ago

Thank you very much!

I will give it a look and come back to you because I am also working on this.

jProgr commented 3 years ago

Thank you very much for your contribution.

First of all, you should know that this project is uncopyrighted (see details) and any contribution will also become part of the public domain. Do you accept this?

As previously stated, I am also working on the issue presented on #9, so next time please say that you are interested in working on one issue so no effort is wasted. For the implementation I used a somewhat complex regex, your idea seems better. Whilst I was implementing the exact match feature I noticed that the class ElementSearcher was doing way too much and I think a refactoring is needed. I also noticed this in your implementation. The search(query) method is way to complex, it is 4 levels of deep flow control. I do try to avoid deep levels of nesting because the code tends to grow in complexity.

I like your implementation of the exact match by using sets, I think this will become the algorithm but there is some refactoring needed:

Your pull request will be accepted. I can make the changes listed after the fact. What do you think?

mitaa commented 3 years ago

First of all, you should know that this project is uncopyrighted (see details) and any contribution will also become part of the public domain. Do you accept this?

Yes, of course.

As previously stated, I am also working on the issue presented on #9, so next time please say that you are interested in working on one issue so no effort is wasted.

Sorry about that, I'll make sure to do so in the future.

Your pull request will be accepted. I can make the changes listed after the fact. What do you think?

Your comments make sense. If you can make those changes I'm all for it since you were already working on it and I'm a bit lost on the style side of things anyway.

jProgr commented 3 years ago

Thanks again :)