Open bpwhelan opened 1 week ago
I am not familiar with how Yomitan is displaying that information, including that detail would make it easier for me to visualize exactly what is being asked here.
Regardless, here are a few things to keep in mind if you intend to create a PR for this:
1) Users who don't wish to use it (including me, since I don't mine at all) shouldn't have to pay for it. In other words, the existence of this feature shouldn't make lookups any slower for users who don't wish to use it. 2) Even for users who choose to opt into using it, its performance impact should be minimal. If a user has lots of dictionaries and happens to look up a word written in kana, JL might list lots of results. If you want this information to be shown for all results without any interaction, its performance impact might not be acceptable. Of course, this may depend on whether Anki Connect allows us to fetch the required information in batches, etc. However, if such an approach proves to have an unacceptable performance impact, then a different approach should be taken, such as requiring a button press on a specific result to show whether it's a duplicate.
I probably won't be implementing this feature myself because I don't personally have a use for it, and its performance characteristics might not be acceptable. So, if you decide not to create a PR for it, feel free to close this issue.
Sure.
TL;DR, my plan is to only trigger it on "mining button pressed", and it will just be an icon with a tooltip.
This icon turns red when there already exists a card with that exact expression,
Here is how Yomitan displays it. It also allows you to open the anki note with the button to the left of that (the book), which would also be nice to have, but I don't want to add any buttons, JL seems to be more focused on playing rather than mining, which i totally agree with.
This will likely just end up being an icon somewhere along this line with a hover over to show a tooltip saying there already exists a card in the deck configured. This could also potentially come in the form of a different font over the word, but I don't really want to change anything or make anything confusing.
This would only be processed/shown when the "mining" button is clicked, so there is no impact whatsoever to normal lookups (if possible).
Just theoretically speaking the performance impact should be minimal, but I will have to test some to know concretely.
By no means is done, but seems to be mostly working with what I slapped in there. If you have any general design asks let me know. I'll probably sit on it for a while and actually make sure it's clean before I PR.
This would only be processed/shown when the "mining" button is clicked
Do you mean it would only be shown when you click on the primary spelling that allows you to mine the word (e.g., 屋, written in orange in your screenshot)? Or do you mean it would only be shown when the "Mining mode" button/hotkey (e.g., middle mouse button/Alt+M) is pressed, which enables the mining mode?
If you mean the former, then what's the plan exactly? Currently, when you click on the primary spelling, JL will try to mine it and close the popup regardless of the operation’s success. If there’s an error, it will be shown as an "alert" in the upper-right corner of the screen; if successful, it will show an alert like "Mined {Primary Spelling}". Would you want the popup to remain open if the card you try to create is a duplicate, to show the "duplicate" icon? Would an alert like "Mined duplicate card" suffice in that case?
If you mean the latter, I’m afraid it does count as a normal lookup, because the Mouse click/Touch
and Text select
lookup modes both enable mining mode by default. Mouse click/Touch
is used by many people, so its performance is pretty important.
If you have any general design asks let me know
1) Go with a design that would have the least impact on the performance.
For example, showing an alert like "Mined {Primary Spelling} (Duplicate)" after we mine the term would be pretty trivial and it would have basically zero performance overhead. Asking "This card is a duplicate, are you really sure you want to mine it anyway?" after user clicks on the primary spelling would also have basically zero performance overhead. If any of these designs would suffice for your use-case, please prefer them over checking the duplicate-ness of every result in mining mode.
If the abovementioned approaches wouldn't be useful for your use-case and you need to see the duplicate-ness of every result in mining mode with a glance, then create an option to enable this feature and make the default value of that option false. I'd also appricate it if you can test this feature's performance impact with lots of dictionaries.
2) JL allows users to mine to a text file as well but we probably shouldn't check the content of the file to detect if the result we are trying to mine is a duplicate or not. So the duplication check should only be done if Preferences -> Advanced -> Mine to file instead of Anki
is disabled.
3) Make sure your code doesn't introduce a new warning/suggestion in Visual Studio/Rider.
I have the latter implemented currently, i did think about just changing the notification to show that it's a duplicate, but for me there is still useful information in the mining screen that would come from checking "everything" for duplicates.
Simple example, if i have an existing card for 目標 and the word is 目標的, that might influence my decision to mine 目標的 (like, i absolutely don't need a card)
I will check out what you mentioned about left click counting as mining mode when i get home, all my logic is hidden under if miningmode as of right now, but i just threw it in there without much care just for my personal use.
If you mean the latter, I’m afraid it does count as a normal lookup, because the
Mouse click/Touch
andText select
lookup modes both enable mining mode by default.Mouse click/Touch
is used by many people, so its performance is pretty important.
Ah, I was confused by this at first but i see now... I was doing hover and then middle mouse to go into mining. I think there is a performance hit, but im not sure. Regardless i will re-think my approach a bit.
This would be a useful feature to have similar to Yomitan's implementation for a few reasons. I feel duplicate cards are useful for some words that require a lot of different context to really undersand. Few other reasons..
I might look at adding this and PRing, since it would be super helpful for my setup, but no promises.