Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JavaScript algorithm to match text as closely as possible (but not identical)

Options
  • 18-02-2015 11:12pm
    #1
    Registered Users Posts: 2,421 ✭✭✭


    Hi there,

    Do you have any advice for a JavaScript algorithm, which searches through a database of strings of text to find multiple matches as closely related as possible to one particular string.

    For example:
    I ate a chicken

    Database:
    I think I ate bad chicken for my lunch
    I had chicken salad for breakfast
    Had I eaten breakfast, I would have felt better.

    It would be a large database and will have to repeat hundreds of times for different searches.


Comments

  • Registered Users Posts: 11,977 ✭✭✭✭Giblet


    You would use an indexer of some sort for this, such as Solr or Elastic Search (both based on Lucene).


  • Registered Users Posts: 1,275 ✭✭✭bpmurray


    I've never hear of fuzzy matching written in JavaScript - that sounds rather ambitious. Instead, use something like Lucene as Giblit suggested - FuzzyQuery might be what you want.


  • Registered Users Posts: 2,030 ✭✭✭colm_c


    Depends on the overall solution, but I don't think a client side JS will be up to the job, here's a node module which might help:
    https://github.com/mattyork/fuzzy


  • Registered Users Posts: 2,421 ✭✭✭embraer170


    Thanks all for your help, I will be doing some digging based on these references.


Advertisement