@ablanc/reverso-api 中文文档教程

发布于 4年前 浏览 19 更新于 3年前

reverso-api

使用 reverso 拼写检查 API 的 node.js 模块。

Table of Contents

Installation

npm install @ablanc/reverso-api

# or with yarn
yarn add @ablanc/reverso-api

Usage

import { checkSpelling } from '@ablanc/reverso-api';

async function test() {
  const res = await checkSpelling({ text: 'salut les amis' });

  console.log(res);
}

test();

以下是您在调用 checkSpelling 时可以覆盖的属性:

interface Params {
  autoReplace?: boolean;
  generateSynonyms?: boolean;
  getCorrectionDetails?: boolean;
  interfaceLanguage?: string;
  language?: 'fra' | 'eng';
  locale?: string;
  origin?: string;
  text: string;
}

结果对象应如下所示:

interface Result {
  id: string;
  language: string;
  text: string;
  engine: 'Cordial' | 'Ginger';
  truncated: boolean;
  timeTaken: number;
  corrections: Correction[];
  sentences: any[];
  autoReplacements: any[];
}

interface Correction {
  group: string;
  type: string;
  shortDescription: string;
  longDescription: string;
  startIndex: number;
  endIndex: number;
  mistakeText: string;
  correctionText: string;
  suggestions: Suggestion[];
}

interface Suggestion {
  text: string;
}

reverso-api

A node.js module to use reverso spell checking API.

Table of Contents

Installation

npm install @ablanc/reverso-api

# or with yarn
yarn add @ablanc/reverso-api

Usage

import { checkSpelling } from '@ablanc/reverso-api';

async function test() {
  const res = await checkSpelling({ text: 'salut les amis' });

  console.log(res);
}

test();

Here are the properties you can override when calling checkSpelling :

interface Params {
  autoReplace?: boolean;
  generateSynonyms?: boolean;
  getCorrectionDetails?: boolean;
  interfaceLanguage?: string;
  language?: 'fra' | 'eng';
  locale?: string;
  origin?: string;
  text: string;
}

The result object should look like this :

interface Result {
  id: string;
  language: string;
  text: string;
  engine: 'Cordial' | 'Ginger';
  truncated: boolean;
  timeTaken: number;
  corrections: Correction[];
  sentences: any[];
  autoReplacements: any[];
}

interface Correction {
  group: string;
  type: string;
  shortDescription: string;
  longDescription: string;
  startIndex: number;
  endIndex: number;
  mistakeText: string;
  correctionText: string;
  suggestions: Suggestion[];
}

interface Suggestion {
  text: string;
}
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文