@@ -618,44 +618,6 @@ export function isFullWidthCharacter(charCode: number): boolean {
618618 ) ;
619619}
620620
621- /**
622- * Computes the difference score for two strings. More similar strings have a higher score.
623- * We use largest common subsequence dynamic programming approach but penalize in the end for length differences.
624- * Strings that have a large length difference will get a bad default score 0.
625- * Complexity - both time and space O(first.length * second.length)
626- * Dynamic programming LCS computation http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
627- *
628- * @param first a string
629- * @param second a string
630- */
631- export function difference ( first : string , second : string , maxLenDelta : number = 4 ) : number {
632- let lengthDifference = Math . abs ( first . length - second . length ) ;
633- // We only compute score if length of the currentWord and length of entry.name are similar.
634- if ( lengthDifference > maxLenDelta ) {
635- return 0 ;
636- }
637- // Initialize LCS (largest common subsequence) matrix.
638- let LCS : number [ ] [ ] = [ ] ;
639- let zeroArray : number [ ] = [ ] ;
640- let i : number , j : number ;
641- for ( i = 0 ; i < second . length + 1 ; ++ i ) {
642- zeroArray . push ( 0 ) ;
643- }
644- for ( i = 0 ; i < first . length + 1 ; ++ i ) {
645- LCS . push ( zeroArray ) ;
646- }
647- for ( i = 1 ; i < first . length + 1 ; ++ i ) {
648- for ( j = 1 ; j < second . length + 1 ; ++ j ) {
649- if ( first [ i - 1 ] === second [ j - 1 ] ) {
650- LCS [ i ] [ j ] = LCS [ i - 1 ] [ j - 1 ] + 1 ;
651- } else {
652- LCS [ i ] [ j ] = Math . max ( LCS [ i - 1 ] [ j ] , LCS [ i ] [ j - 1 ] ) ;
653- }
654- }
655- }
656- return LCS [ first . length ] [ second . length ] - Math . sqrt ( lengthDifference ) ;
657- }
658-
659621/**
660622 * Returns an array in which every entry is the offset of a
661623 * line. There is always one entry which is zero.
@@ -782,4 +744,4 @@ export function fuzzyContains(target: string, query: string): boolean {
782744 }
783745
784746 return true ;
785- }
747+ }
0 commit comments