@@ -302,6 +302,7 @@ var main = (data, increase) => {
302
302
const highlightFunc = ( t ) => {
303
303
304
304
const find = ( word , phrase , literal , mustPreceed ) => {
305
+ console . log ( word , phrase )
305
306
const letters = 'abcdefghijklmnopqrstuvwxyzабвгдежзийклмнопрстуфхцчшщъыьэюяєії'
306
307
let index = 0 ;
307
308
let parenthesis = 0 ;
@@ -318,7 +319,7 @@ var main = (data, increase) => {
318
319
const beforeClear = isBeginning || ! letters . includes ( phrase [ i - 1 ] . toLowerCase ( ) ) ;
319
320
const afterClear = isEnd || ! letters . includes ( phrase [ i + 1 ] . toLowerCase ( ) ) ;
320
321
321
- const isWordMatch = thisLetter . toLowerCase ( ) === word [ index ] ;
322
+ const isWordMatch = thisLetter . toLowerCase ( ) . replaceAll ( 'ї' , 'і' ) . replaceAll ( 'ґ' , 'г' ) === word [ index ] ;
322
323
const isAccent = thisLetter === "́" ;
323
324
324
325
if ( index === 0 ) {
@@ -532,10 +533,11 @@ function searchHelper() {
532
533
}
533
534
let indexes ;
534
535
const canInclude = fuzzyWords . length === 1 && fuzzyWords [ 0 ] . replace ( / [ ^ a - z ] / g, '' ) . length === 0 ;
535
- for ( const word of fuzzyWords ) {
536
+ for ( let word of fuzzyWords ) {
536
537
if ( ! word ) break ;
537
538
// generate words containing all searched letters
538
539
let wordIndexes ;
540
+ word = word . replaceAll ( 'ї' , 'і' ) . replaceAll ( 'ґ' , 'г' )
539
541
for ( const l of new Set ( word ) ) {
540
542
if ( ! wordIndexes ) wordIndexes = wordDict [ l ] ;
541
543
else {
@@ -564,9 +566,10 @@ function searchHelper() {
564
566
}
565
567
}
566
568
console . log ( literalWords )
567
- for ( const word of literalWords ) {
569
+ for ( let word of literalWords ) {
568
570
if ( ! word ) break ;
569
571
// generate words containing all searched letters
572
+ word = word . replaceAll ( 'ї' , 'і' ) . replaceAll ( 'ґ' , 'г' )
570
573
let wordIndexes ;
571
574
for ( const l of new Set ( word ) ) {
572
575
if ( ! wordIndexes ) wordIndexes = wordDict [ l ] ;
@@ -607,7 +610,7 @@ function searchHelper() {
607
610
else if ( l === ')' ) paren -- ;
608
611
else if ( paren === 0 ) noParen += l ;
609
612
}
610
- return noParen . toLowerCase ( ) . includes ( literalRes )
613
+ return noParen . toLowerCase ( ) . replace ( 'ї' , 'і' ) . replace ( 'ґ' , 'г' ) . includes ( literalRes )
611
614
}
612
615
613
616
const unpack = ( y ) => {
@@ -624,8 +627,8 @@ function searchHelper() {
624
627
let goodData = d3 . filter (
625
628
allData ,
626
629
x => (
627
- d3 . filter ( x . defs , filterFunc ) + d3 . filter ( unpack ( x . forms ) , y => { return y . replaceAll ( '\u0301' , '' ) === literalRes ; } )
628
- ) . length > 0 || x . word . replaceAll ( '\u0301' , '' ) === literalRes
630
+ d3 . filter ( x . defs , filterFunc ) + d3 . filter ( unpack ( x . forms ) , y => { return y . replaceAll ( '\u0301' , '' ) . replaceAll ( 'ї' , 'і' ) . replaceAll ( 'ґ' , 'г' ) === literalRes ; } )
631
+ ) . length > 0 || x . word . replaceAll ( '\u0301' , '' ) . replaceAll ( 'ї' , 'і' ) . replaceAll ( 'ґ' , 'г' ) === literalRes
629
632
) . map ( x => x . index )
630
633
631
634
const _indexes = d3 . filter ( Array . from ( indexes ) , x => goodData . includes ( x ) )
@@ -660,8 +663,9 @@ function search(changeURL = true) {
660
663
const letters = "abcdefghijklmnopqrstuvwxyzабвгдежзийклмнопрстуфхцчшщъыьэюяєіїґ '\""
661
664
const oldSearch = searchTerm ;
662
665
searchTerm = document . querySelector ( 'input#search' ) . value . toLowerCase ( ) ;
663
- searchTerm = searchTerm . replace ( '“' , '"' ) . replace ( '”' , '"' ) . replace ( '«' , '"' ) . replace ( '»' , '"' )
664
- searchTerm = searchTerm . replace ( '‘' , "'" ) . replace ( '’' , "'" ) . replace ( '‛' , "'" )
666
+ searchTerm = searchTerm . replaceAll ( '“' , '"' ) . replaceAll ( '”' , '"' ) . replaceAll ( '«' , '"' ) . replaceAll ( '»' , '"' )
667
+ searchTerm = searchTerm . replaceAll ( '‘' , "'" ) . replaceAll ( '’' , "'" ) . replaceAll ( '‛' , "'" )
668
+ searchTerm = searchTerm . replaceAll ( 'ї' , 'і' ) . replaceAll ( 'ґ' , 'г' ) // letter normalization
665
669
let newSearchTerm = ''
666
670
for ( const s of searchTerm ) { if ( letters . includes ( s ) ) newSearchTerm += s ; }
667
671
searchTerm = newSearchTerm ;
0 commit comments