Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opex-yandex-speller

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opex-yandex-speller

This package provides a convenient way to interact with the Yandex Speller API for spell checking in Russian, Ukrainian, and English languages.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
0
Weekly downloads
 
Created
Source

Yandex Speller API

This package provides a convenient way to interact with the Yandex Speller API for spell checking in Russian, Ukrainian, and English languages.

Terms of Use

Limits

10.000 requests/day

  • (Limit on the number of calls to the Service - on average 10 thousand calls per day);

10.000.000 chars/day

  • The limit on the volume of text to be checked is an average of 10 million characters per day.

Installation

npm install opex-yandex-speller

Usage

You can import the package using ES6 modules or CommonJS require:

// ES6 import
import { YandexSpeller } from 'opex-yandex-speller';

// CommonJS require
const { YandexSpeller } = require('opex-yandex-speller');

API Reference

YandexSpeller Class

The main class for interacting with the Yandex Speller API.

Constructor
const speller = new YandexSpeller(settings);
  • settings (optional): An object with the following properties: - format (string): Text format, either 'plain' (default) or 'html'. - lang (string): Languages for spell checking, comma-separated. Default: 'en,ru'. - options (object): Speller options (see below). - requestLimit (number): Maximum number of request attempts. Default: 2. - timeout (number): Timeout between request attempts in milliseconds. Default: 500.
Speller Options
  • ignoreDigits (boolean): Ignore words with numbers, e.g., "avp17h4534".
  • ignoreUrls (boolean): Ignore URLs, email addresses, and filenames.
  • findRepeatWords (boolean): Highlight repeated words, e.g., "I flew to to to Cyprus".
  • ignoreCapitalization (boolean): Ignore incorrect use of capitalization, e.g., "moscow" instead of "Moscow".

Methods

checkText(text)

Checks the spelling of a given text.

  • text (string): The text to check.
  • Returns: A Promise that resolves to an array of spelling errors.

Example:

const speller = new YandexSpeller();

async function checkSpelling() {
		try {
				const result = await speller.checkText('testt textt');
				console.log(result);
		} catch (error) {
				console.error('Error:', error.message);
		}
}

checkSpelling();
checkTexts(texts)

Checks the spelling of multiple text fragments.

  • texts (array of strings): An array of text fragments to check.
  • Returns: A Promise that resolves to an array of arrays, each containing spelling errors for the corresponding text fragment.

Example:

const speller = new YandexSpeller();

async function checkMultipleTexts() {
		try {
				const result = await speller.checkTexts(['testt textt', 'anoter exammple']);
				console.log(result);
		} catch (error) {
				console.error('Error:', error.message);
		}
}

checkMultipleTexts();

Error Codes

The API uses the following error codes:

  • ERROR_UNKNOWN_WORD (1): Unknown word.
  • ERROR_REPEATED_WORD (2): Repeated word.
  • ERROR_CAPITALIZATION (3): Capitalization error.
  • ERROR_TOO_MANY_ERRORS (4): Too many errors.

You can import these constants:

import { ERROR_UNKNOWN_WORD, ERROR_REPEATED_WORD, ERROR_CAPITALIZATION, ERROR_TOO_MANY_ERRORS } from 'opex-yandex-speller';

Response Format

The API returns an array of error objects. Each error object has the following structure:

  • code (number): The error code (see above).
  • pos (number): The position of the error in the text (0-based).
  • row (number): The row number of the error (0-based).
  • col (number): The column number of the error (0-based).
  • len (number): The length of the erroneous word.
  • word (string): The word with the error.
  • s (array of strings): Suggested corrections.

Example response:

[
		{
				code: 1,
				pos: 0,
				row: 0,
				col: 0,
				len: 5,
				word: "testt",
				s: ["test", "tests"]
		},
		{
				code: 1,
				pos: 6,
				row: 0,
				col: 6,
				len: 5,
				word: "textt",
				s: ["text"]
		}
]

Acknowledgments

This package is a wrapper for the Yandex Speller API. Please refer to their documentation for more detailed information about the service.

Package developer

OpexDev

Keywords

FAQs

Package last updated on 20 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc