Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Thanks, threading question and thoughts #128

Unanswered
kestasjk asked this question in Q&A
Thanks, threading question and thoughts #128
Mar 9, 2022 * 1 comments * 1 reply
Return to top
Discussion options

kestasjk
Mar 9, 2022

Thanks for the library, very useful. So far it seems to be much better than NetSpell and hunspell and aspell , which is impressive for such a small code base.

It would be good to have capitals in the dictionaries; it's useful for recognizing proper words. Also if I'm only reading from the dictionary, doing lookups etc, is it thread safe? I wouldn't expect it to be while entering data into the dictionary, but if I'm just reading can I use one dictionary from multiple threads?

Cheers,

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

wolfgarbe
Mar 9, 2022
Maintainer

Capitals
WordSegmentation retains/preserves the case of input text.
But to allow capitals in the dictionary would have the following drawbacks:

  • Capitals are used not only for proper words, but also in sentence start or in headlines. So, most of the time both forms are valid. Then almost always both forms would be displayed as suggestion, making suggestions cluttered.
  • That would also significantly increase the dictionary size and RAM consumption

But I'm open to any suggestion solving the problems mentioned above consistently.

Threads
Lookup is thread safe, as long as there are no LoadDictionary, CreateDictionary, and CreateDictionaryEntry in parallel.

But if you want to incrementally update your dictionary with CreateDictionaryEntry, then both Lookup and CreateDictionaryEntry have to be synchronized by locks. While you could use a simple Lock(), a ReaderWriterLockSlim ensures better performance, because it still allows multiple Lookups in parallel:
#90 (comment)

You must be logged in to vote
1 reply
Comment options

kestasjk Mar 9, 2022
Author

Hmm.. I was thinking more along the lines of places and people, where if you looked it up in a dictionary it would be capitalized. Are you saying there's no reason the current system can't do these it's just about the dictionary?
I guess I see what you mean about how it would offer the non-capitalized version as a correction for sentence starts that are capitalized, but isn't that a "problem" now anyway? I would have thought it would be up to the developer to handle that case.

Thanks for the info on locking. I've got a dictionary shared among 8 cores and all 8 go 100%, and I can spellcheck a database of 1.3M words in a couple of minutes whereas before I had to leave it for a couple of hours, and with multiple languages and a couple of domain specific dictionaries added in, so it's scaling and performing very nicely indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants