Coder Social home page Coder Social logo

Fuzzy search about sol HOT 4 OPEN

thgh avatar thgh commented on June 5, 2024
Fuzzy search

from sol.

Comments (4)

ospfranco avatar ospfranco commented on June 5, 2024

Sol is no longer open source due people launching other products by forking the code.

Fuzzy search is implemented via fuse.js, with the following params:

export const FUSE_OPTIONS: Fuse.IFuseOptions<any> = {
  threshold: 0.15,
  ignoreLocation: true,
  findAllMatches: true,
  keys: [
    {name: 'name', weight: 0.9},
    {name: 'alias', weight: 0.1},
  ],
}

I don't think implementing something like "vsc" is possible with that library.

from sol.

thgh avatar thgh commented on June 5, 2024

Well that's sad to hear. What kind of products?

Here is what ChatGPT would do:

To configure fuse.js to find matches based on word initials, you can use the "tokenize" option and set it to a function that splits the search query into individual words and their initials. Here's an example:

const fuse = new Fuse(list, {
  keys: ['title', 'author'],
  tokenize: (query) => {
    const words = query.trim().toLowerCase().split(' ');
    return words.flatMap((word) => {
      const initials = Array.from(word).map((char) => `${char}*`).join('');
      return [word, initials];
    });
  },
});

In this example, the "tokenize" function takes the search query, splits it into individual words, and then maps each word to an array that contains the word itself and its initials with an asterisk appended to each character. For example, the query "vsc" would be transformed to ["vsc", "vsc*"].

By doing this, when you search for "vsc", Fuse.js will match it with any string in the list that contains "v", "s", and "c" as consecutive characters, such as "Visual Studio Code".

from sol.

ospfranco avatar ospfranco commented on June 5, 2024

God I hate chatGPT, not an intelligent answer as that will probably mess up every other result.

For example, vsc seems to work on spotlight but only for vscode, so it probably has an alias registered somewhere, not some random tokenizer running on all items.

from sol.

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.