Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

[Feature Request] Improve ease of setting dictionary priority #1539

Open
Thermospore opened this issue Mar 18, 2021 · 12 comments
Open

[Feature Request] Improve ease of setting dictionary priority #1539

Thermospore opened this issue Mar 18, 2021 · 12 comments

Comments

@Thermospore
Copy link
Contributor

The current system of typing in a priority number works great for smaller numbers of dictionaries, but once you have more than a handful it becomes difficult to manage. For example if you have 20 dictionaries/freq lists and want to add one to the middle of the stack, you have to scroll around and bump up each of the top 10 one by one

I recall the titles used to sort themselves by priority on the settings page, which made it a bit easier. It was still a hassle to manually bump around each priority number though

Anyone have ideas of how to improve it? Drag to sort, maybe?

@toasted-nutbread
Copy link
Collaborator

Having the order of dictionaries be more configurable would probably fix the issue (either drag-and-drop or an option to move up/down), but there are currently some implementation issues that make this difficult without some prior rework.

I recall the titles used to sort themselves by priority on the settings page, which made it a bit easier.

Yes, but IMO this isn't a great UX, as it's jarring if a UI element jumps around on the page after editing a text input field.

@Thermospore
Copy link
Contributor Author

Yes, but IMO this isn't a great UX, as it's jarring if a UI element jumps around on the page after editing a text input field.

Hmm yeah I recall that too. What if the position didn't update until the next time the menu was opened?

@toasted-nutbread
Copy link
Collaborator

I've made some changes to how dictionary options are presented in #1640, and added the ability to rearrange the options in #1641. Once this is in a release, let me know if that's helpful for this request.

@Thermospore
Copy link
Contributor Author

Sure thing, thanks!!

@Thermospore
Copy link
Contributor Author

Thermospore commented May 2, 2021

New compact style looks nice 🙂

possible bug:
I had prefix wildcards enabled for my dicts but the UI shows them disabled now
image

seems they are still enabled internally
image

I think there are currently two concerns:

  1. you can't rearrange a dictionary to its final location in the list with a single action; if you want to move it n spots over you have to press the move button n times
  2. you still need to perform some manual numbering gymnastics to reorder the priorities

perhaps something like how you rearrange the fields of a card type in Anki would be an easy solution?
image
(ie you just type in the desired position and the list is automatically rearranged and renumbered)

@Thermospore
Copy link
Contributor Author

Sweet! I have some feedback, now that I'm able to play with it myself:
https://youtu.be/mo0Ao9DIAqU

enumerated for easy reference:

  1. remove the manual priority boxes and have that numbering on the left hand side be the priority number
  2. make the priority number a rank, ie 1 = 1st = most priority (to keep the settings and search page in the same order)
  3. currently when you set a new position number, the two dictionaries swap places. instead, the other dictionaries should slide out of the way (see above anki ui example)

I think this would be ideal, for the reasons explained in the vid

(I'd be willing to submit a pull request but I'm pretty sure it's beyond my ability 👀 )

@toasted-nutbread
Copy link
Collaborator

I'm hesitant to remove the priority number, at least right now, since there may be users that use or prefer that method, or maybe want to use both. There's really not much information available about how people use Yomichan and what features are/aren't used, which can be both good and bad.

For ordering by the index/rank, this is technically already done, but it's done at a stage that is potentially later than it should be. I could probably make the dictionaryIndex comparison occur just after the dictionaryPriority comparison and it would function as you describe, assuming all priorities are set to 0.

_sortTermDictionaryEntries(dictionaryEntries) {
const stringComparer = this._stringComparer;
const compareFunction = (v1, v2) => {
// Sort by length of source term
let i = v2.maxTransformedTextLength - v1.maxTransformedTextLength;
if (i !== 0) { return i; }
// Sort by the number of inflection reasons
i = v1.inflections.length - v2.inflections.length;
if (i !== 0) { return i; }
// Sort by how many terms exactly match the source (e.g. for exact kana prioritization)
i = v2.sourceTermExactMatchCount - v1.sourceTermExactMatchCount;
if (i !== 0) { return i; }
// Sort by dictionary priority
i = v2.dictionaryPriority - v1.dictionaryPriority;
if (i !== 0) { return i; }
// Sort by term score
i = v2.score - v1.score;
if (i !== 0) { return i; }
// Sort by headword term text
const headwords1 = v1.headwords;
const headwords2 = v2.headwords;
for (let j = 0, jj = Math.min(headwords1.length, headwords2.length); j < jj; ++j) {
const term1 = headwords1[j].term;
const term2 = headwords2[j].term;
i = term2.length - term1.length;
if (i !== 0) { return i; }
i = stringComparer.compare(term1, term2);
if (i !== 0) { return i; }
}
// Sort by dictionary order
i = v1.dictionaryIndex - v2.dictionaryIndex;
return i;
};
dictionaryEntries.sort(compareFunction);
}

@Thermospore
Copy link
Contributor Author

Ohh I see so you can simply set all the priority numbers the same, making the sort rely on dictionaryIndex. Seems to work! That plus #1667 should cover all of the functionality I was looking for. Thanks!!
image

@Thermospore
Copy link
Contributor Author

#1667 working well so far, thanks again

@Thermospore
Copy link
Contributor Author

For ordering by the index/rank, this is technically already done, but it's done at a stage that is potentially later than it should be. I could probably make the dictionaryIndex comparison occur just after the dictionaryPriority comparison and it would function as you describe, assuming all priorities are set to 0.

oh whoops I didn't read that correctly the first time (just got my covid vaccine; totally out of it lol)

@Thermospore Thermospore reopened this May 12, 2021
@Thermospore
Copy link
Contributor Author

Yeah the grouping isn't done properly when all the priorities are set the same, with the current sort code
image

@toasted-nutbread
Copy link
Collaborator

By "grouping" do you mean "ordering"? It's expected that the ordering is not the same as it's currently designed, and I don't think that the order can be used the same as the priority, because that will cause dictionary the order of entries to be incorrect. I.e., the definitions of the first dictionary would always come before any other dictionary, even if later dictionaries have definitions that match better due to a higher score. Related: #1668

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants