2023-08-04 17:59:02 +00:00
|
|
|
import {db, getWords} from './db.mjs'
|
2023-08-03 18:26:26 +00:00
|
|
|
import Spellchecker, { isMisspelled } from 'spellchecker'
|
|
|
|
|
2023-08-04 17:59:02 +00:00
|
|
|
|
2023-08-03 18:26:26 +00:00
|
|
|
|
|
|
|
const words = await getWords(db)
|
|
|
|
console.dir(words)
|
|
|
|
for (const element of words) {
|
|
|
|
if(isMisspelled(element.word)){
|
|
|
|
try {
|
|
|
|
await db('dictionary')
|
|
|
|
.where('word', element.word)
|
|
|
|
.del()
|
|
|
|
console.log("deleted non-word " + element.word)
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error.message)
|
|
|
|
} finally {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
db.destroy()
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error.message)
|
|
|
|
}
|