happy bday!
This commit is contained in:
17
clean.ts
Normal file
17
clean.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import dictionary from './en_eo_dict.json' assert { type: 'json' };
|
||||
|
||||
const wordRegex = /^[a-z]+$/;
|
||||
const cleanDict = dictionary
|
||||
.filter(({ word }) => wordRegex.test(word))
|
||||
.filter(({ translation }) => wordRegex.test(translation))
|
||||
.filter((e) => e.snc_index === null)
|
||||
.reduce((acc, cur) => {
|
||||
const wordExists = acc.some((item) => item.word === cur.word);
|
||||
const translationExists = acc.some((item) => item.translation === cur.translation);
|
||||
if (wordExists || translationExists) return acc;
|
||||
|
||||
return [...acc, cur];
|
||||
}, [] as typeof dictionary)
|
||||
.map(({ word, translation }) => ({ word, translation }));
|
||||
|
||||
await Bun.write('en_eo_dict_clean.json', JSON.stringify(cleanDict, null, 2));
|
||||
Reference in New Issue
Block a user