mattyork / fuzzy Goto Github PK
View Code? Open in Web Editor NEWFilters a list based on a fuzzy string search
License: MIT License
Filters a list based on a fuzzy string search
License: MIT License
Hi, there are some warnings in your code
Condition always true [./~/fuzzy/lib/fuzzy.js:16,0]
Dropping unreachable code [./~/fuzzy/lib/fuzzy.js:19,0]
Dropping unused variable compareChar [./~/fuzzy/lib/fuzzy.js:51,0]
Dropping unused variable root [./~/fuzzy/lib/fuzzy.js:11,0]
Hi, I am doing something like this. when i select the answer.answers returns empty string
function searchUser(answers, input) {
var names = [ { name: "Test1", accountId: "a746hsjikel" }, { name: "Test2", accountId: "982bjkkgkbnd" } ]
return new Promise(function(resolve) {
setTimeout(function() {
var options = {
extract: function(el) {
return el.name;
}
};
var fuzzyResult = fuzzy.filter(input, names, options);
resolve(
fuzzyResult.map(function(el) {
return el.string;
})
);
}, 2000);
});
}
inquirer
.prompt([
{
type: "autocomplete",
name: "test",
message: "Search user",
source: searchUsers,
pageSize: 4,
suggestOnly: true
}
])
.then(function(answers) {
console.log(JSON.stringify(answers, null, 2));
});
It's best for libs, and means we don't have to manually manage the definition file
Need an easy way to compare changes for perf
I was just wondering how I would go about hilighting my search results like done so on the Disney Demo I can't see to figure it out.
Right now fuzzy returns formatted string results like this:
"<b>t</b>est"
That doesn't work well with clients that don't insert into the DOM with innerHTML, like React. Need to find a better way
It's common to filter lists with mixed-type data. fuzzy currently throws an error if you pass it a number value.
One workaround is to convert numbers to strings before passing values to fuzzy. The downside to this approach is that you have to throw out (sometimes essential) type information about your data. Ideally, fuzzy would handle both strings and numbers internally, return values that preserve the original type.
I'm reopening a new issue relating to issue #27 since it was closed prematurely.
Hi, I'm using these module with node but I have long JSON Array contain object. I need matched object whole. Like
var list = [
{rompalu: 'baconing', zibbity: 'simba'}
, {rompalu: 'narwhal' , zibbity: 'mufasa'}
, {rompalu: 'a mighty bear canoe', zibbity: 'saddam hussein'}
];
I have above list of JSON Array and if I pass word narwhal
than It's return only matched words in Array but I need array of matched object. output like :
[
{rompalu: 'narwhal' , zibbity: 'mufasa'}
]
Creating a PR for this, let me know if this is not desired!
Thanks for building this nice, simple library!
I'd like to provide the user with a default option in the event that their search returns no results. Something simple like "No results found" but that can be customized as well. Is that something you'd be interested in a PR for?
i have read two csv files and put into as list of JSON objects.
Iam trying to match two list of json objects and fetch the matching data.
I implmented this with fuzzy logic, Using fuzzy.filter (string,list) i can able to compare against the list of json objects, can anyone suggest me some solutions
here is my sample code:
read.csvReadJson(function(petdata1) {
read.readCSV(function(petdata2) {
petdata1.forEach(function(petdata) {
for(var i=0;i<=petdata2.length;i++){
//matching string with list of json objects
var results = fuzzy.filter(petdata.breed, petdata2[i])
var matches = results.map(function(el) { return el.string; });
console.log(matches);
if (matches !=" "){
console.log(matches);
}
}
in the above example petdata1 and petdata2 are list of JSON objects.
can anyone please help me out
Hi,
as it doesn't seem this lib is still maintained, I started to re implement the lib taking in consideration some of the issue raised here.
Such as #26 or #25 and #45
In case I was wrong and this lib is still maintained, then I don't mind to delete it and merge the different improvement here.
Link to the new lib: https://github.com/Nexucis/fuzzy
Hello, Thanks for this great library !
Is it possible to use an object like this :
var list = {
1: {id: 1, rompalu: 'baconing', zibbity: 'simba'},
2: {id: 2, rompalu: 'narwhal' , zibbity: 'mufasa'},
3: {id: 3, rompalu: 'a mighty bear canoe', zibbity: 'saddam hussein'}
}
instead of a list like :
var list = [
{rompalu: 'baconing', zibbity: 'simba'}
, {rompalu: 'narwhal' , zibbity: 'mufasa'}
, {rompalu: 'a mighty bear canoe', zibbity: 'saddam hussein'}
];
Thanks for the response !
https://www.npmjs.com/package/fuzzy
This still links to https://github.com/myork/fuzzy.
The last commit is 1.5 years ago. Is there a maintainer or this project is left?
Do we have any plan to actually maintain this library?
Hi,
Is it possible to match an exact text? For example, i want to retrieve the results for all value that as "thisvalue" but not the other resultats that contain these letter for example "this poor value".
Thanks!
I'd be much more likely to download the library if there was a place I could go to actually see it in action, test it out, and see if it's what I want. I'd rather not download it if it's not really what I want. Even screenshots of it working would be useful.
Search string: che
[ { string: 'Teachers Credit Union', score: 11, index: 136 },
{ string: 'Teachers Chemical', score: 11, index: 20 }
{ string: 'Chevron Valley CU', score: 11, index: 270 },
]
But Chevron Valley CU
should score higher than Teachers Credit Union
since Chevron
starts with che
while Teachers
only has a substring che
. Additionally, Teachers Chemical
score higher since a word inside the string begins with chec
(even though it's not the first word inside the string).
It would be very helpful if an option could be set so that fuzzy would return strings with and without diacritics.
e.g.: The user searches for "Lumiere"
The result should also include "Lumière":
Lumière
Lümière
Lumiere
Lůmière
Lúmière
You won't find "Lumiere" in this official example:
http://htmlpreview.github.io/?https://github.com/mattyork/fuzzy/blob/master/examples/disney.html
I'm getting the error with the following trace:
match
fuzzy.js: 50
filter
fuzzy.js :115
as soon as I try to filter for even a single character. I've verified my input is a string and the list I'm filtering against is an array of objects with only string values.
Sorry I cannot cut and paste the error msgs as I'm using this in a React Native app and the error is reported in the Android emulator.
What I want to archive is the mentioned in the tests as todo.
// TODO: Dont know how I feel about this. Sublime weights characters that
// appear toward the beginning of the string a bit higher
https://github.com/mattyork/fuzzy/blob/master/test/fuzzy.test.js#L51
The practical usecase is that i have a list with languages and for eng
the first result is not english
, but bengalish
.
Not sure if an exact duplicate, but at least related to: #3 and I guess already fixed in #12
is there a way to remove the "item": {}
object wrapping each of my results from Fuse that's wrapping my results data? I just want the bare results of my data, not in an object with other props such as refIndex
and what not.
I just want the raw data back, having this wrapped is causing me pain because I have to now somehow get that out of the dataset returned by Fuse.
In disney.html, the matching letters don't turn bold until the next key is pressed.
In directors.html, if I type in "ee", it seems like the only matches brought up are ones with that exact match. No words appear in which there are two e's that are not consecutive. That might be because there's some limit on the number of matches shown. I haven't yet figured out how to find that setting.
There is a use case where I always want to return a match, no matter how bad it is. Can this be done?
Hi,
I try to use your lib with ionic2
npm install https://github.com/mattyork/fuzzy.git#typescript --save
import { fuzzy } from 'fuzzy';
error
throw new Error("Cannot find module "fuzzy"");
any idea ?
thx
Are you still working on this? This would be a great improvement.
I use this library for my (sublime-go-to-anything-like) chrome extension Tab Ahead.
I'm not even sure what to actually call this and I think it's more of a feature request than an issue. Is there any way currently to do a search for something like "Bill Smith" and have it return content that's formatted as "Smith, Bill"?
Similar to #15, I'm having an issue where "div" is an exact substring match but fuzzy matches are ranked above.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.