Skip to content

Commit

Permalink
Switch to new API Speller (#24)
Browse files Browse the repository at this point in the history
* Switch to new API Speller

* Bump version
  • Loading branch information
hcodes committed Nov 11, 2023
1 parent f2e4dba commit df8613a
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 126 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 6.0.0
Switch to new Yandex Speller API.
Removed unsupported API options:
- IGNORE_UPPERCASE
- IGNORE_LATIN
- NO_SUGGEST
- FLAG_LATIN
- BY_WORDS
- IGNORE_ROMAN_NUMERALS

## 5.0.0
- Drop support Node.js < 16.
- Fix timeout event.
Expand All @@ -17,13 +27,12 @@ Removed unsupported API options:
- IGNORE_UPPERCASE
- IGNORE_DIGITS
- FIND_REPEAT_WORDS
- IGNORE_LATIN:
- IGNORE_LATIN
- NO_SUGGEST
- FLAG_LATIN
- BY_WORDS
- IGNORE_CAPITALIZATION
- IGNORE_ROMAN_NUMERALS
- IGNORE_CAPITALIZATION

## 2.1.0
Repeating server request in case of internet connection issues #1 @Avetome
Expand Down
18 changes: 3 additions & 15 deletions lib/yandex-speller.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,12 @@ function checkTexts(texts, callback, settings) {

function prepareOptions(options) {
let result = 0;
// https://tech.yandex.ru/speller/doc/dg/reference/speller-options-docpage/
// https://yandex.ru/dev/speller/doc/ru/reference/speller-options
const standartOptions = {
IGNORE_UPPERCASE: 1,
IGNORE_DIGITS: 2,
IGNORE_URLS: 4,
FIND_REPEAT_WORDS: 8,
IGNORE_LATIN: 16,
NO_SUGGEST: 32,
FLAG_LATIN: 128,
BY_WORDS: 256,
IGNORE_CAPITALIZATION: 512,
IGNORE_ROMAN_NUMERALS: 2048,
};

Object.keys(options || {}).forEach(function(key) {
Expand Down Expand Up @@ -126,16 +120,10 @@ function prepareSettings(settings) {
* @param {number} [requestLimit] Request repeat count in case internet connection issues.
* @param {number} [timeout] Timeout between request repeats in milliseconds.
* @param {Object} [options]
* @param {boolean} [options.ignoreUppercase] Ignore words written in capital letters.
* @param {boolean} [options.ignoreDigits] Ignore words with numbers, such as "avp17h4534".
* @param {boolean} [options.ignoreUrls] Ignore Internet addresses, email addresses and filenames.
* @param {boolean} [options.findRepeatWords] Highlight repetitions of words, consecutive. For example, "I flew to to to Cyprus".
* @param {boolean} [options.ignoreLatin] Ignore words, written in Latin, for example, "madrid".
* @param {boolean} [options.noSuggest] Just check the text, without giving options to replace.
* @param {boolean} [options.flagLatin] Celebrate words, written in Latin, as erroneous.
* @param {boolean} [options.byWords] Do not use a dictionary environment (context) during the scan. This is useful in cases where the service is transmitted to the input of a list of individual words.
* @param {boolean} [options.ignoreCapitalization] Ignore the incorrect use of UPPERCASE / lowercase letters, for example, in the word "moscow".
* @param {boolean} [options.ignoreRomanNumerals] Ignore Roman numerals ("I, II, III, ...").
*/

module.exports = {
Expand All @@ -147,11 +135,11 @@ module.exports = {

errors,
errorCodes: errors, // Deprecated

ERROR_UNKNOWN_WORD,
ERROR_REPEATED_WORD,
ERROR_CAPITALIZATION,
ERROR_TOO_MANY_ERRORS,

supportedFormats: ['plain', 'html']
};
120 changes: 60 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "yandex-speller",
"main": "./lib/yandex-speller.js",
"description": "Yandex Speller API for Node.js",
"version": "5.0.0",
"version": "6.0.0",
"license": "MIT",
"homepage": "https://github.com/hcodes/yandex-speller",
"repository": {
Expand All @@ -30,10 +30,10 @@
],
"devDependencies": {
"chai": "^4.3.10",
"eslint": "^8.52.0",
"eslint": "^8.53.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"sinon": "^17.0.0"
"sinon": "^17.0.1"
},
"engines": {
"node": ">=16"
Expand Down
Loading

0 comments on commit df8613a

Please sign in to comment.