@@ -75,15 +75,13 @@ export const getLangsFromYaml = (): Map<string, StringSet> => {
75
75
)
76
76
) ;
77
77
78
- const langsOrderedByNumSpeakers : Map <
79
- string ,
80
- StringSet
81
- > = allLangsByNumSpeakers . reduce ( ( newLs , l ) => {
82
- if ( langs . has ( l ) ) {
83
- newLs . set ( l , langs . get ( l ) as StringSet ) ;
84
- }
85
- return newLs ;
86
- } , new Map < string , StringSet > ( ) ) ;
78
+ const langsOrderedByNumSpeakers : Map < string , StringSet > =
79
+ allLangsByNumSpeakers . reduce ( ( newLs , l ) => {
80
+ if ( langs . has ( l ) ) {
81
+ newLs . set ( l , langs . get ( l ) as StringSet ) ;
82
+ }
83
+ return newLs ;
84
+ } , new Map < string , StringSet > ( ) ) ;
87
85
const langsWithUnknownSpeakers = [ ...langs ] . filter (
88
86
( [ l ] ) => ! langsOrderedByNumSpeakers . has ( l )
89
87
) ;
@@ -165,18 +163,19 @@ export const getLangIdSubstrings = (
165
163
} ;
166
164
167
165
const mostPromisingSubstrings = new Map < string , Map < string , StringSet > > (
168
- [ ...substringsMap ] . sort ( (
169
- [ ss1 , lTm1 ] ,
170
- [ ss2 , lTm2 ] // ss == substring, lTm == languageTranslationMap
171
- ) =>
172
- ss1 . length !== ss2 . length || lTm1 . size !== lTm2 . size
173
- ? // sort short substrings and substrings with few language matches before others
174
- ss1 . length +
175
- [ ...lTm1 ] . reduce ( ignoreDuplicateTranslations , [ ] ) . length -
176
- ( ss2 . length +
177
- [ ...lTm2 ] . reduce ( ignoreDuplicateTranslations , [ ] ) . length )
178
- : // if we can’t distinguish that way, sort substrings that match many translations first
179
- [ ...lTm2 ] [ 0 ] [ 1 ] . size - [ ...lTm1 ] [ 0 ] [ 1 ] . size
166
+ [ ...substringsMap ] . sort (
167
+ (
168
+ [ ss1 , lTm1 ] ,
169
+ [ ss2 , lTm2 ] // ss == substring, lTm == languageTranslationMap
170
+ ) =>
171
+ ss1 . length !== ss2 . length || lTm1 . size !== lTm2 . size
172
+ ? // sort short substrings and substrings with few language matches before others
173
+ ss1 . length +
174
+ [ ...lTm1 ] . reduce ( ignoreDuplicateTranslations , [ ] ) . length -
175
+ ( ss2 . length +
176
+ [ ...lTm2 ] . reduce ( ignoreDuplicateTranslations , [ ] ) . length )
177
+ : // if we can’t distinguish that way, sort substrings that match many translations first
178
+ [ ...lTm2 ] [ 0 ] [ 1 ] . size - [ ...lTm1 ] [ 0 ] [ 1 ] . size
180
179
)
181
180
) ;
182
181
0 commit comments