Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

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

  • 18-02-2015 11:12PM
    #1
    Registered Users, Registered Users 2 Posts: 2,445 ✭✭✭


    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, Registered Users 2 Posts: 12,025 ✭✭✭✭Giblet


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


  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 2,011 ✭✭✭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, Registered Users 2 Posts: 2,445 ✭✭✭embraer170


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


Advertisement