Git Product home page Git Product logo

detectlanguage's Introduction

Detect Language API (Discontinued)

JavaScript wrapper for DetectLanguage Service.

 

Important Notice

This repository has been discontinued, please go here for an updated version: https://github.com/detectlanguage/detectlanguage-node

   

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 http://detectlanguage.com

 

Usage

Setup

var DetectLanguage = require('detectlanguage');
var detectLanguage = new DetectLanguage({
    key: '[INSERT YOUR KEY HERE]',
    ssl: true|false (defaults to TRUE)
});    

Simple Detection

Takes a simple string and detects the language with a list of detections.

Request
var dataSimple = "I am a Teapot and a Submarine";
detectLanguage.detect(dataSimple, function(error, result) {
    console.log(JSON.stringify(result));
});
Response
{
  data: {
    detections: [
      {
        language: "en",
        isReliable: true,
        confidence: 7.85
      }
    ]
  }
}

Bulk Detection (Recommended)

Takes an array simple string and detects the language with a list of detections.

Request
var dataBulk = [
    "I am a Teapot and a Submarine",
    "Soy una tetera y un submarino",
    "Jeg er en tekande og en ubåd"
]
detectLanguage.detect(dataBulk, function(error, result) {
    console.log(JSON.stringify(result));
});
Response
{
  data: {
    detections: [
      [
        {
          language: "en",
          isReliable: true,
          confidence: 7.85
        }
      ],
      [
        {
          language: "es",
          isReliable: true,
          confidence: 3.75
        }
      ],
      [
        {
          language: "da",
          isReliable: true,
          confidence: 4.09
        }
      ]
    ]
  }
}

Supported Languages

Returns the list of supported languages.

Request
detectLanguage.languages(function(error, result) {
    console.log(JSON.stringify(result));
});
Response
[
  {
    code: "ab",
    name: "ABKHAZIAN"
  },
  {
    code: "aa",
    name: "AFAR"
  },
  {
    code: "af",
    name: "AFRIKAANS"
  }
  ...
]

User Status

Returns information about your account and it's status.

Request
detectLanguage.status(function(error, result) {
    console.log(JSON.stringify(result));
});
Response
{
  date: "2015-02-21",
  requests: 31,
  bytes: 429,
  plan: "FREE",
  plan_expires: null,
  daily_requests_limit: 5000,
  daily_bytes_limit: 1048576,
  status: "ACTIVE"
}

 

Author

Peter Andreas Moelgaard (GitHub, Twitter)

 

License

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

detectlanguage's People

Contributors

laurynas avatar pmoelgaard avatar

Watchers

 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.