Code Monkey home page Code Monkey logo

Comments (6)

krisk avatar krisk commented on June 5, 2024 1

@derhuerst, I am not following. As it has been mentioned, the nature of Bitap is such that you'd have to pre-compute the score of the items against the search term before any sorting can take place. Ergo, I cannot see how Fuse would yield the top n items out of m without having calculated m number of scores.

from fuse.

AdamGaskins avatar AdamGaskins commented on June 5, 2024

Can you just break after iterating through the display loop 5 times?

from fuse.

derhuerst avatar derhuerst commented on June 5, 2024

My problem is that many more results get computed. My problem is not about displaying the results.

from fuse.

AdamGaskins avatar AdamGaskins commented on June 5, 2024

My understanding of the Bitap algorithm is that it has to process every item to calculate a score for it. The sorting can only happen after this.

For example if you search for egg on this list:

["rEfriGeratorG", "salad", "EGGplant"]

And then cancel the search after it reaches the second item, it will return refrigeratorG as the best match, when if you let it finish, eggplant obviously would have been better.

You could still add a feature that limits the amount of results it spits out, but that's just the same as doing:

var results = fuse.search("stuff");
for(var i = 0; i < results.length; i++) {
    // do stuff to display result

    if(i > 4) break;
}

from fuse.

derhuerst avatar derhuerst commented on June 5, 2024

No, you could make the sorting itself more efficient. What I wrote today (for a different purpose) can be used for this as well: hifo.

from fuse.

jeancroy avatar jeancroy commented on June 5, 2024

you can do a top-k sorting but I believe most of the time is spent computing score. As AtmoEntity pointed out there's no way out of scoring everything to guarantee showing the best result.

from fuse.

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.