Skip to content
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

Any suggestion on how to use this library for real-time word suggestions? #43

Closed
ACCIAI0 opened this issue Feb 14, 2022 · 5 comments
Closed

Comments

@ACCIAI0
Copy link

ACCIAI0 commented Feb 14, 2022

I'm trying to use WeCantSpell to create an autocorrect feature for a project I'm working on. I call WordsList.Suggest every time a new letter is added/removed from the word I'm writing but the results are generated very slowly, the more letters i feed into the method, the more time it takes to compute a result. Is there any way I can make it run faster? Is there a way to limit the number of words to retrieve as suggestions?

@aarondandy
Copy link
Owner

I think this relates to #40 in that the suggest feature is definitely very computationally slow. There may be room for optimization there but due to being a port the algorithm is what it is. I think this is a good suggestion though and goes along with the linked PR. I have been thinking of adding some kind of overload to the suggest feature to accept some optional arguments such as a cancellation token to do away with the weird timer logic, but also I think your suggestion of returning after reaching an upper limit of suggestions may be a good one.

@ACCIAI0
Copy link
Author

ACCIAI0 commented Feb 14, 2022

The cancellation token could actually be very helpful in my application, especially in conjuction with the use of an upper limit of suggestions. For the time being I suppose I could just override subsequent calls by halting the thread I run the Suggest method on and wait only for the latest call to terminate and see how it goes. It might not be as performant as I hoped for, but at least it shouldn't freeze the UI while typing.

@aarondandy
Copy link
Owner

Let me know if this release candidate works for you all: https://www.nuget.org/packages/WeCantSpell.Hunspell/4.0.0-rc01

@aarondandy
Copy link
Owner

I'm refactoring the CancellationToken to be an argument of the Check and Suggest methods instead of a property on options as I think that makes a lot more sense.

@aarondandy
Copy link
Owner

@ACCIAI0 See if the new release works better for you: https://www.nuget.org/packages/WeCantSpell.Hunspell/4.0.0
You can supply a CancellationToken as an argument to the Suggest and Check methods now but also configure some timeout values using the options argument on those methods. Feel free to re-open if you think there is something else that can be done for this use case.

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

No branches or pull requests

2 participants