Code Monkey home page Code Monkey logo

Comments (4)

wooorm avatar wooorm commented on May 22, 2024

From my experience, and knowledge implementing suggestions, is that they’re always very slow.

Thus, the simplest would be to cap the amount of words you find suggestions for: for example, at 10.
Showing if a word is misspelt or not is a much cheaper operation, so you can still show wrongly spelt words at pretty okay speed.

Another thing is to add a cache: often the same words are misspelt over and over, and there’s no need to look up suggestions for the same word multiple times.

from nodehun.

Arnoku avatar Arnoku commented on May 22, 2024

@wooorm I thank you for your rapid response
I do indeed use optimizations for the latter thing you mentioned - filter out the same words. For the specific thing I'm trying to make, I don't need suggestions, only to have the word be checked against a .dic/.aff dictionary, and figure out if the word is in the dictionary or not, I've tried using both suggest and isCorrect methods, since I assume the isCorrect method should work much faster, since it doesn't return suggestions, which might explain why it takes more time, since the method itself on the inside does more operations I assume
Why I'm asking all this is I've tried using PHP's spellchecker before and I've gotten up to 2000 requests per 5 seconds by simply caching the dictionary file into memory, so this is why I'm curious if I'm doing anything wrong here?
Thank you again for taking time to read and respond to my questions, cheers

from nodehun.

wooorm avatar wooorm commented on May 22, 2024

What’s your code? What dictionary do you use in PHP, and what in Node?

from nodehun.

Arnoku avatar Arnoku commented on May 22, 2024

I've managed to figure it out, thanks a million, I've been doing it wrongly, instead of caching the physical files themselves (dictionaries), if you cache the nodehun objects, that's how you get MUCH faster response times.
My bad, thank you so much nonetheless!

from nodehun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.