All Projects → kwonoj → hunspell-asm

kwonoj / hunspell-asm

Licence: MIT license
WebAssembly based Javascript bindings for hunspell spellchecker

Programming Languages

typescript
32286 projects
shell
77523 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to hunspell-asm

spacy hunspell
✏️ Hunspell extension for spaCy 2.0.
Stars: ✭ 94 (+56.67%)
Mutual labels:  hunspell, spellchecker
hunspell
High-Performance Stemmer, Tokenizer, and Spell Checker for R
Stars: ✭ 101 (+68.33%)
Mutual labels:  hunspell, spellchecker
Intelligent Document Finder
Document Search Engine Tool
Stars: ✭ 45 (-25%)
Mutual labels:  spellchecker
php-speller
PHP spell check library
Stars: ✭ 66 (+10%)
Mutual labels:  hunspell
Hunspell
Ruby wrapper for the famous spell checker library hunspell.
Stars: ✭ 34 (-43.33%)
Mutual labels:  hunspell
vscode-languagetool-linter
A from scratch redesign of LanguageTool integration for VS Code.
Stars: ✭ 72 (+20%)
Mutual labels:  spellchecker
retext-spell
plugin to check spelling
Stars: ✭ 53 (-11.67%)
Mutual labels:  spell
contextualSpellCheck
✔️Contextual word checker for better suggestions
Stars: ✭ 274 (+356.67%)
Mutual labels:  spellchecker
mingw-w64-texmacs
TeXmacs for Windows (build in MSys2/Mingw32 environment)
Stars: ✭ 21 (-65%)
Mutual labels:  spellchecker
ka GE.spell
ქართული ორთოგრაფიული ლექსიკონი - Georgian Spell Checking Dictionary
Stars: ✭ 24 (-60%)
Mutual labels:  hunspell
Semantic-Textual-Similarity
Natural Language Processing using NLTK and Spacy
Stars: ✭ 30 (-50%)
Mutual labels:  spellchecker
elasticsearch-croatian
Elasticsearch compatible Hunspell dictionary for Croatian.
Stars: ✭ 16 (-73.33%)
Mutual labels:  hunspell
customized-symspell
Java port of SymSpell: 1 million times faster through Symmetric Delete spelling correction algorithm
Stars: ✭ 51 (-15%)
Mutual labels:  spellchecker
gramatika.app
Website of Gramatika check spelling and typo tools in Bahasa Indonesia
Stars: ✭ 72 (+20%)
Mutual labels:  spell
kotlin-java-spellchecker
A simple spellcheckers on Java and Kotlin
Stars: ✭ 13 (-78.33%)
Mutual labels:  spellchecker
WordSegmentationDP
Word Segmentation with Dynamic Programming
Stars: ✭ 18 (-70%)
Mutual labels:  spellchecker
viconf
My (n)Vim config files
Stars: ✭ 18 (-70%)
Mutual labels:  spellchecker
cyberdic
An auxiliary spellcheck dictionary that corresponds with the Bishop Fox Cybersecurity Style Guide
Stars: ✭ 63 (+5%)
Mutual labels:  hunspell
spellchecker-wasm
SpellcheckerWasm is an extrememly fast spellchecker for WebAssembly based on SymSpell
Stars: ✭ 46 (-23.33%)
Mutual labels:  spellchecker
Angry-Reviewer
Style corrector for academic writing and scientific papers at angryreviewer.com
Stars: ✭ 69 (+15%)
Mutual labels:  spellchecker

Build Status Build status codecov npm node

Hunspell-asm

Hunspell-asm is isomorphic javascript binding to hunspell spellchecker based on WebAssembly hunspell binary. This module aims to provide thin, lightweight interface to hunspell without requiring native modules.

Install

npm install hunspell-asm

Usage

Loading module asynchronously

Hunspell-asm relies on wasm binary of hunspell, which need to be initialized first.

import { loadModule } from 'hunspell-asm';

const hunspellFactory = await loadModule();

loadModule loads wasm binary, initialize it, and returns factory function to create instance of hunspell.

loadModule({ timeout?: number }): Promise<HunspellFactory>

It allows to specify timeout to wait until wasm binary compliation & load.

Mounting files

Wasm binary uses different memory spaces allocated for its own and cannot access plain javascript object / or files directly. HunspellFactory provides few interfaces to interop file contents into hunspell.

  • mountBuffer(contents: ArrayBufferView, fileName?: string): string : Mount contents of file.
  • unmount(mountedFilePath: string) : Unmount path if it's exists in memory. If it's bufferFile created by mountBuffer, unmount will remove those file object in wasm memory as well.

All of virtual paths for mounted filesystem uses unix separator regardless of platform.

Creating spellchecker

Once you mounted dic / aff files you can create hunspell spellchecker instance via HunspellFactory::create. Each path for files are mounted path and should not be actual path or server endpoint.

create(affPath: string, dictPath: string): Hunspell

Hunspell exposes minimal interfaces to spellchecker.

  • spell(word: string): boolean : Check spelling for word. False for misspelled, True otherwise.
  • suggest(word: string): Array<string> : Get suggestion list for misspelled word. Empty if word is not misspelled or no suggestions.
  • dispose(): void : Destroy current instance of hunspell. It is important to note created instance of hunspell will not be destroyed automatically.

There are simple examples for each environments using different apis. In each example directory do npm install && npm start.

Adding words to dictionary in runtime

Hunspell exposes few interfaces allow to add words, or dictionaries in existing dictionary in runtime. This is runtime behavior, so it doesn't persist over once instance is disposed.

  • addWord(word: string): void : add single word to current dictionary.
  • removeWord(word: string): void : remove single word from current dictionary.
  • addWordWithAffix(word: string, affix: string): void: add word with example word having affix flag to be applied. Second param affix is example word, should exists in current dictionary with its own affix flag. Newly added word will have same affix rule as example word.
  • addDictionary(dictPath): boolean : Load addtional dictionary into existing hunspell instance. This cannot load additional affi x. If function returns false, it means internal slot hunspell manages are full and can't add additional dictionaries.

Things to note

  • Ensure all inputs (aff, dic, word for spell / suggest) are UTF-8 encoded correctly. While hunspell itself supports other encodings, all surrounding interfaces passing buffers are plain javascript doesn't detect / converts encodings automatically.

Building / Testing

Few npm scripts are supported for build / test code.

  • build: Transpiles code to ES5 commonjs to dist.
  • test: Run hunspell / hunspell-asm test both. Does not require build before execute test.
  • test:hunspell: Run integration test for actual hunspell wasm binary, using hunspell's test case as-is.
  • test:hunspell-asm: Run unit test against hunspell-asm interface
  • lint: Run lint over all codebases
  • lint:staged: Run lint only for staged changes. This'll be executed automatically with precommit hook.
  • commit: Commit wizard to write commit message

License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].