Ajatt-Tools / anki.koplugin

KOReader plugin enabling Anki card generations for words looked up in the internal dictionary.
57 stars 6 forks source link

Question: Only one setting allowed? #36

Open Steven630 opened 1 month ago

Steven630 commented 1 month ago

Hello, thank you for creating this useful plugin. I'm looking into a possible way to memorize words and come upon this plugin. I wonder if there is just one setting allowed. I look up words in three languages, and would like to add them to different decks depending on the language. Is this possible? In the config.lua, it seems the setting is fixed. Thank you.

nairyosangha commented 1 month ago

Yeah the setting is fixed currently, you can only have one. I messed around a while back with having multiple profiles, see this branch https://github.com/Ajatt-Tools/anki.koplugin/tree/MULTI_PROFILE_SUPPORT

the idea being that you would create multiple config.lua files with unique names under a new 'profiles' directory, which you can then associate with the document you're reading. It's not finished though, haven't really touched it in a while since I haven't really needed it myself

Steven630 commented 1 month ago

Thank you for the reply. I'll first try the fixed setting then. Does the plugin require a lot of CPU though? Hope it doesn't crash on my kpw2 (sometimes looking up a word in the dictionary crashes my Koreader😊)

Steven630 commented 1 month ago

I have just tried it out on my Android phone. It seems there is no notification when a card has been stored offline. Can the user change the default context length to at least a certain number of words? Sometimes a sentence contains words like "Mr." ,"U.S.A". To customize one by one is a bit slow. My suggestion is to let users to set a threshold. If the context is, say, less than 15 words when using the default extraction, the surrounding two sentences are added until the criterion is met.

nairyosangha commented 1 month ago

Thank you for the reply. I'll first try the fixed setting then. Does the plugin require a lot of CPU though? Hope it doesn't crash on my kpw2 (sometimes looking up a word in the dictionary crashes my Koreader😊)

I would expect it to work fine, my old kobo aura manages fine

I have just tried it out on my Android phone. It seems there is no notification when a card has been stored offline.

It only notifies you the first time so you're not constantly told a note was stored offline, certain popups are only shown if the previously shown popup wasn't exactly the same, which was an easy way to make it less spammy.

Can the user change the default context length to at least a certain number of words? Sometimes a sentence contains words like "Mr." ,"U.S.A". To customize one by one is a bit slow. My suggestion is to let users to set a threshold. If the context is, say, less than 15 words when using the default extraction, the surrounding two sentences are added until the criterion is met.

That's also not configurable, you can just select the context you want with the custom context menu though, isn't that good enough :thinking:

Would it be okay if the threshold applies to both the part before the word looked up and the part after separately? E.g. if the sentence part before the word looked up is fewer than 15 words it adds an extra sentence until we have more than 15 words. Same thing would happen for the part after the sentence. KOreader returns the context as the part before and after the string separately so that'd make it cleaner to implement

Steven630 commented 1 month ago

Would it be okay if the threshold applies to both the part before the word looked up and the part after separately? E.g. if the sentence part before the word looked up is fewer than 15 words it adds an extra sentence until we have more than 15 words. Same thing would happen for the part after the sentence. KOreader returns the context as the part before and after the string separately so that'd make it cleaner to implement

Yes, setting threshold for both previous and next context would be nice. I personally prefer more contexts, so customizing frequently would be a bit inconvenient. (And there are the annoying Mr. Mrs. that cut a sentence short).

TonioBanderas commented 1 month ago

Yeah the setting is fixed currently, you can only have one. I messed around a while back with having multiple profiles, see this branch https://github.com/Ajatt-Tools/anki.koplugin/tree/MULTI_PROFILE_SUPPORT

the idea being that you would create multiple config.lua files with unique names under a new 'profiles' directory, which you can then associate with the document you're reading. It's not finished though, haven't really touched it in a while since I haven't really needed it myself

This would be so awesome :)

nairyosangha commented 5 days ago

I've added a prev_sentence_count and next_sentence_count setting. Leave it at 1 to have the current behavior, setting it to 2 will prepend/append one extra sentence, etc.

nairyosangha commented 5 days ago

I've also added support for having multiple profiles. Instead of having the single config.lua you can now just drop multiple .lua files in the ./profiles directory and then link them with a doc. I've updated the readme, I hope it's pretty self explanatory, please let me know if something is unclear