25 lines
758 B
JavaScript
25 lines
758 B
JavaScript
|
|
import { SpellChecker } from './dist/spellcheck/index.js';
|
||
|
|
|
||
|
|
async function test() {
|
||
|
|
const spellChecker = new SpellChecker({
|
||
|
|
dictionaries: ['english', 'technical'],
|
||
|
|
customWords: ['vitest', 'uwuapps'],
|
||
|
|
autoCorrect: true,
|
||
|
|
threshold: 0.3
|
||
|
|
});
|
||
|
|
|
||
|
|
await spellChecker.initialize();
|
||
|
|
|
||
|
|
const text = 'This is a test with som mispeled words';
|
||
|
|
const result = await spellChecker.checkText(text);
|
||
|
|
|
||
|
|
console.log('Total errors:', result.errors.length);
|
||
|
|
console.log('Error words:', result.errors.map(e => e.word));
|
||
|
|
console.log('Full errors:', JSON.stringify(result.errors, null, 2));
|
||
|
|
|
||
|
|
// Also test just 'som' alone
|
||
|
|
const somResult = await spellChecker.check('som');
|
||
|
|
console.log('som check result:', somResult);
|
||
|
|
}
|
||
|
|
|
||
|
|
test().catch(console.error);
|