Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/megahertz/spech
Check your text for grammar and spelling mistakes using multiple providers
https://github.com/megahertz/spech
Last synced: 20 days ago
JSON representation
Check your text for grammar and spelling mistakes using multiple providers
- Host: GitHub
- URL: https://github.com/megahertz/spech
- Owner: megahertz
- License: mit
- Created: 2019-12-13T18:40:00.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-07T12:58:04.000Z (over 1 year ago)
- Last Synced: 2024-05-16T14:04:38.925Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 517 KB
- Stars: 31
- Watchers: 1
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spech
[![Build Status](https://travis-ci.org/megahertz/spech.svg?branch=master)](https://travis-ci.org/megahertz/spech)
[![NPM version](https://badge.fury.io/js/spech.svg)](https://badge.fury.io/js/spech)Check your text for grammar and spelling mistakes using multiple providers
- Multiple libraries/services for grammar and spelling checking
- Multilingual document support
- Zero config
- Can work offline (only with Hunspell provider)![Screenshot](docs/img/screenshot.png)
## Usage
### Files checking
`npx spech README.md`
File name can be omitted, by default it searches files by `**/*.md` mask.
Default language is English, it can be changed with `-l` flag:`spech -l ru`
`spech -l ru-RU -l en-US` - for multilingual documents
### String and STDIN checking
You can check a string value using STDIN or --input argument
`cat README.md | spech`
`spech --input 'Check the text'`
### Directives
#### disable
```Markdown
This text is ignored
```
#### dictionary
Add a phrase to a local document dictionary
```Markdown
```
#### languages
Add document-specific languages
```Markdown
```
## Providers
To configure a provider pass `-p` flag:
`spech -p hunspell -p yandex`
Other options can be set in a config file.
### Hunspell
Hunspell is the most popular open-source spell checker which supports a great
variety of languages.[Read more](docs/providers/hunspell.md).
### GrammarBot
Free grammar checking API. With an API key, you can receive 250 requests/day
(~7500/mo) at no cost. Without an API key, requests are limited to 100 per
day per IP address (~3000/mo). The API supports only English (en-US and en-GB).[Read more](docs/providers/grammarBot.md).
### Yandex Speller
Free and very fast spell checker API for en, ru and uk languages. It provides
free 10k requests/day or 10m characters/day.[Read more](docs/providers/yandex.md).
## [Configuring](docs/config.md)
Configuration can be stored in:
- spech.config.js
- "spech" section of the package.jsonspech.config.js
```js
module.exports = {
languages: ['en-us'],
providers: [
{ name: 'hunspell' },
{ name: 'grammarBot', apiKey: 'YOUR_API_KEY' },
],
};
```[More details](docs/config.md).
### Dictionaries
It's possible to add words which are marked as a mistake into a dictionary file.
Just create a file with .dic extension in your project root:mydictionary.dic
```
# Simple word
browserify
# Regexp
/Component.tsx?/
```[More details](docs/config.md#dictionaries-string--string).
## API Usage
The most useful parts of the library are available through facade class
[SpellChecker](src/SpellChecker.js).Here is a simple example how it can be used:
```js
const { Config, SpellChecker } = require('spech');async function getMistakes() {
const config = new Config({ ignoreCase: false });
const checker = new SpellChecker(config);await checker.addDocumentsByMask(process.cwd(), 'docs/*.md');
checker.addDictionaryPhrase('exceptionphrase');
checker.addProviderByConfig({ name: 'hunspell' });const noMistakes = await checker.checkDocuments();
if (noMistakes) {
return [];
}
const corrections = checker.documents.map(doc => doc.corrections).flat();
return corrections.map(correction => correction.fragment);
}
```