-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Q] Add custom words to loaded dictionary? #41
Comments
I designed the implementation/port to be read-only and immutable. There could be thread safety issues with mutating a dictionary after it is loaded and the use case I was targeting at the time was strictly about quickly checking words. Now, lets say for example you wanted to support something such as "Add words to dictionary." The way I would recommend implementing that is to keep a separate dictionary (it doesn't even need to be hunspell) and use that for your other words. If you do want to use this lib for that custom dictionary, for suggestions as an example, it would have to be rebuilt for each new word. Now if this is to become a feature request, that is a pretty interesting feature but would be very difficult to implement safely I think considering how spaghetti like the code is already 🍝 . I cleaned it up as best I could though, but it definitely feels like a challenging feature. |
I just had a thought, one way this could be practical is based on how I had to create a "query" object to represent each suggestion and check call. I did this initially to move all the global/static variables into there so that queries could be made in parallel. This could be leveraged so that each running query could grab a reference to the immutable internal variables that make up a dictionary and affix structure. A mutation to the entire structure could possibly be done in an atomic way by cleverly swapping references around maybe. 🤔 |
@aarondandy is there more information about this question? I have the same problem that I need to implement custom user dictionaries for spellchecking and suggesting capabilities. I was using |
Nothing has changed yet, for now I recommend keeping two dictionaries. One dictionary from file, such as an en-us dictionary, and another dictionary in memory for the user's custom words. Example: https://github.com/aarondandy/WeCantSpell.Hunspell/blob/2c95ea91a1ca40a36b3b5dab219ca38dd613eebb/test/WeCantSpell.Hunspell.Tests/WordListTests.cs |
@aarondandy Just as a side note, if I'm not mistaken, NHunspell dictionaries are also immutable, the words are added/removed to/from the available instance in memory. Once the dictionary is reloaded, the added words are gone and the removed words are back. |
Hello,
I didn't find any ticket or test about adding custom words to a loaded dictionary.
Is it possible?
Or do it need to re-create a new dictionary by merging?
Thanks,
Hervé
The text was updated successfully, but these errors were encountered: