hi all,
was reading this thread. It deals with duplicates where my question below does not (only when it comes to foldernames). A fuzzy search in Everything would be great (Filelocator Pro, an entirely different - and slower - approach to searching than Everything, has it).
I was wondering if it would be possible to match duplicate folder names in a collection by percentage (say: of the total number of characters in a foldername a 'x' percentage has to be identical and has to show up in the results). Is any such approach to fuzzy name-search possible already?
thanks in advance! kazzy
Fuzzy search for folders
-
- Posts: 383
- Joined: Thu Dec 15, 2016 9:44 pm
Re: Fuzzy search for folders
Fuzzy searches don't necessarily represent how humans would do things.
For example, you could scan the two-letter sequences of your search phrase,
e.g. "Hello World" you would have He el ll lo "o " " W" Wo or rl ld
score a point for each that exists in the target, and divide that score by the score for an exact match, and it's a hit if over a threshold. You don't need to account for where it is found because when the letter pairs are in the correct order you get more hits than when they are out of order.
So "Heeloa Worrld" would match "Hello World" and "World Hello" (slightly lower score).
It's marginly different between whole and part matches.
I'm sure there are other methods, but that's one I came up with for my own purposes, and works very fast for me.
The code I did for those was (in javascript) -
For example, you could scan the two-letter sequences of your search phrase,
e.g. "Hello World" you would have He el ll lo "o " " W" Wo or rl ld
score a point for each that exists in the target, and divide that score by the score for an exact match, and it's a hit if over a threshold. You don't need to account for where it is found because when the letter pairs are in the correct order you get more hits than when they are out of order.
So "Heeloa Worrld" would match "Hello World" and "World Hello" (slightly lower score).
It's marginly different between whole and part matches.
I'm sure there are other methods, but that's one I came up with for my own purposes, and works very fast for me.
The code I did for those was (in javascript) -
Code: Select all
function fuzzywhole(iFlg,sTxt,sFnd) {
// 1 LCase sTxt 2 LCase sFnd
// Method: scan pairs in sFnd and score +1 if in sTxt, final score reduced to 0-1.
var i,iSum=0;
if (!sFnd||!sTxt) return 0;
if (iFlg&1) sTxt=sTxt.toLowerCase();
if (iFlg&2) sFnd=sFnd.toLowerCase();
if (sTxt===sFnd) return 1;
for(i=sFnd.length-2;i>=0;i--) {
if (sTxt.indexOf(sFnd.substr(i,2))>-1) iSum++;
}
if (!iSum) return 0;
return iSum/((sFnd.length+sTxt.length)/2-1);
}
function fuzzypart(iFlg,sTxt,sFnd) {
// 1 LCase sTxt 2 LCase sFnd
// Method: Move a chr window across sTxt a little larger than sFnd and score +1 for pairs entering that are in sFnd and -1 for pairs leaving (0.5 for reversed letters), the score is the max so attained reduced to apx 0-1 (can be >1).
var i,iSum=0,iWnd=0,iMax=0,sMsg='';
if (!sTxt||!sFnd) return 0;
if (iFlg&1) sTxt=sTxt.toLowerCase();
if (iFlg&2) sFnd=sFnd.toLowerCase();
if (sTxt.indexOf(sFnd)>-1) return 1;
iWnd=Math.round(sFnd.length*1.1+1);
for(i=sTxt.length-2;i>=0;i--) {
if (sFnd.indexOf(sTxt.substr(i,2))>-1) iSum++; else if (sFnd.indexOf(sTxt.substr(i+1,1)+sTxt.substr(i,1))>-1) iSum+=0.5;
if (iWnd&&i+iWnd<=sTxt.length-2) {
if (sFnd.indexOf(sTxt.substr(i+iWnd,2))>-1) iSum--; else if (sFnd.indexOf(sTxt.substr(i+iWnd+1,1)+sTxt.substr(i+iWnd,1))>-1) iSum--;
}
if (iSum>iMax) iMax=iSum;
}
if (!iMax) return 0;
return iMax/(sFnd.length-1);
}
Re: Fuzzy search for folders
thanks meteorquake for your extensive reply with explanation and script! I am trying to make it useful, but I am a total n00b when it comes to script (never got past ms-dos and I know how to program my microwave). I looked around on the internet, but did not find an answer yet. How would I be able to make this javascript work (in or out context of Everything Alpha)? Kind regards, kazzy
-
- Posts: 383
- Joined: Thu Dec 15, 2016 9:44 pm
Re: Fuzzy search for folders
The javascript was an example for anyone interested of a simple methodology I had used.
Someone (such as void) would need to do something that will work for Everything...
d
Someone (such as void) would need to do something that will work for Everything...
d
Re: Fuzzy search for folders
![Laughing :lol:](./images/smilies/icon_lol.gif)