0.1.7 • Published 5 months ago

node-symspell-new v0.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Enhanced Node-SymSpell

An enhanced and optimized version of node-symspell, a JavaScript port of SymSpell 6.6, originally developed by Mathieu Loutre, based on the C# version by Wolf Garbe and the Python version by mammothb.

This project improves upon the original by adding new features, optimizing the codebase, and ensuring compatibility with modern environments.


Features

Key Enhancements:

  1. Node.js 22 Compatibility:

    • Updated the code to run seamlessly in Node.js 22 and newer.
  2. Modular Imports:

    • Refactored to support ES module imports, enabling cleaner, modern usage patterns.
  3. Updated Helper Methods:

    • Improved and streamlined helper methods for easier integration.
  4. New Dependency Versions:

    • Replaced older dependencies with newer, more efficient, and secure libraries.
  5. Thorough Testing:

    • Validated with local test cases to ensure stability and correctness.

Installation

You can install this package using npm:

npm install node-symspell-new

Basic Example

import SymSpell, { Verbosity } from 'enhanced-node-symspell'

const maxEditDistance = 2
const prefixLength = 7
const symSpell = new SymSpell(maxEditDistance, prefixLength)

const dictionaryPath = './dictionaries/frequency_dictionary_en_82_765.txt'
const bigramPath = './dictionaries/frequency_bigramdictionary_en_243_342.txt'

// Load dictionaries
await symSpell.loadDictionary(dictionaryPath, 0, 1)
await symSpell.loadBigramDictionary(bigramPath, 0, 2)

// Input text with typos
const typo = 'Can yu readthis messa ge despite thehorible sppelingmsitakes'
const results = symSpell.lookupCompound(typo, maxEditDistance)

// Output the corrected sentence
console.log(results[0])

API Overview

Constructor

new SymSpell(maxDictionaryEditDistance = 2, prefixLength = 7, countThreshold = 1)
  • Initializes the SymSpell object.

Methods

  1. Load Dictionaries:

    • async loadDictionary(dictFile, termIndex, countIndex, separator = ' ')
    • async loadBigramDictionary(dictFile, termIndex, countIndex, separator = ' ')
  2. Lookup Functions:

    • lookup(input, verbosity, maxEditDistance = null, options = {})
    • lookupCompound(input, maxEditDistance = null, options = {})
    • wordSegmentation(input, options = {})

Testing

Run the included test cases to ensure the library is functioning correctly:

npm run test

Credits

This library is built upon the work of:


License

MIT License

0.1.7

5 months ago

0.1.6

6 months ago

0.1.5

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago

0.1.0

6 months ago