1
0
Fork 0

fixed the remove-foreign-words script not to add extra words when used in whitelist mode

This commit is contained in:
sspanak 2024-04-30 16:31:32 +03:00
parent 90288713f1
commit a057e2a4e6

View file

@ -47,7 +47,7 @@ async function work({ isBlacklist, locale, fileName, foreignWordsLocale, foreign
let lineReader = createInterface({ input: createReadStream(fileName) }); let lineReader = createInterface({ input: createReadStream(fileName) });
for await (const line of lineReader) { for await (const line of lineReader) {
originalWords.set(line.toLocaleLowerCase(foreignWordsLocale), line); originalWords.set(line.toLocaleLowerCase(locale), line);
} }
const goodWords = new Set(); const goodWords = new Set();
@ -58,14 +58,14 @@ async function work({ isBlacklist, locale, fileName, foreignWordsLocale, foreign
continue; continue;
} }
const wordKey = line.toLocaleLowerCase(locale); const wordKey = line.toLocaleLowerCase(foreignWordsLocale);
if (isBlacklist && originalWords.has(wordKey)) { if (isBlacklist && originalWords.has(wordKey)) {
originalWords.delete(wordKey); originalWords.delete(wordKey);
} }
if (!isBlacklist && originalWords.has(wordKey)) { if (!isBlacklist && originalWords.has(wordKey)) {
goodWords.add(line); goodWords.add(originalWords.get(wordKey));
} }
} }