Giter Club home page Giter Club logo

detectlanguage-go's Introduction

Detect Language API Node.js Client

npm version Build Status

Node.js wrapper for the Detect Language API.

Installation

npm install detectlanguage [--save]

Configuration

Before using Detect Language API client you have to setup your personal API key. You can get it by signing up at detectlanguage.com

var DetectLanguage = require('detectlanguage');

var detectlanguage = new DetectLanguage('YOUR API KEY');

Usage

Language Detection

Takes a text string and returns a list of detections.

var text = "Hello! How are you?";

detectlanguage.detect(text).then(function(result) {
  console.log(JSON.stringify(result));
});

Response

[
  {
    "language": "en",
    "isReliable": true,
    "confidence": 18.2
  }
]

Batch Detection (recommended)

Takes an array of texts and returns a list of detections. It is much faster than doing request for each text individually.

var texts = ['šešios žąsys', 'Strč prst skrz krk'];

detectlanguage.detect(texts).then(function(result) {
  console.log(JSON.stringify(result));
});

Response

[
  [
    {
      "language": "lt",
      "isReliable": true,
      "confidence": 5.5
    }
  ],
  [
    {
      "language": "cs",
      "isReliable": true,
      "confidence": 3.645
    },
    ...
  ]
]

Language Code Detection

Returns first detected language code.

var text = "Hello! How are you?";

detectlanguage.detectCode(text).then(function(result) {
  console.log(JSON.stringify(result));
});

Response

"en"

Supported Languages

Returns the list of supported languages.

detectlanguage.languages().then(function(result) {
  console.log(JSON.stringify(result));
});

Response

[
  {
    code: "aa",
    name: "AFAR"
  },
  {
    code: "ab",
    name: "ABKHAZIAN"
  },
  {
    code: "af",
    name: "AFRIKAANS"
  }
  ...
]

User Status

Returns information about your account and it's status.

detectlanguage.userStatus().then(function(result) {
  console.log(JSON.stringify(result));
});

Response

{
  date: "2020-01-01",
  requests: 31,
  bytes: 429,
  plan: "FREE",
  plan_expires: null,
  daily_requests_limit: 1000,
  daily_bytes_limit: 1048576,
  status: "ACTIVE"
}

Author

Laurynas Butkus (GitHub)

License

Licensed under the MIT License: https://opensource.org/licenses/MIT

detectlanguage-go's People

Contributors

laurynas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.