Detect Language API Go Client

Detect Language API Go Client

GoDoc Build Status Go Report Card

Detects language of the given text. Returns detected language codes and scores.

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

Installation

go get -u github.com/detectlanguage/detectlanguage-go

Configuration

client := detectlanguage.New("YOUR API KEY")

Usage

Language detection

detections, err := client.Detect("Buenos dias señor")

if err != nil {
    fmt.Fprintln(os.Stderr, "error detecting language:", err)
    os.Exit(1)
    return
}

fmt.Fprintln(os.Stdout, "Language:", detections[0].Language)
fmt.Fprintln(os.Stdout, "Reliable:", detections[0].Reliable)
fmt.Fprintln(os.Stdout, "Confidence:", detections[0].Confidence)

Single language code detection

If you need just a language code you can use DetectCode. It returns first detected language code.

language, err := client.DetectCode("Buenos dias señor")

if err != nil {
    fmt.Fprintln(os.Stderr, "error detecting language:", err)
    os.Exit(1)
    return
}

fmt.Fprintln(os.Stdout, "Language:", language)

Batch detection

It is possible to detect language of several texts with one request. This method is significantly faster than doing one request per text. To use batch detection just pass multiple texts to DetectBatch method.

texts := []string{"labas rytas", "good morning"}
results, err := client.DetectBatch(texts)

if err != nil {
    fmt.Fprintln(os.Stderr, "error detecting language:", err)
    os.Exit(1)
    return
}

fmt.Fprintln(os.Stdout, "First text language:", detections[0][0].Language)
fmt.Fprintln(os.Stdout, "Second text language:", detections[1][0].Language)

Getting your account status

result, err := client.UserStatus()

if err != nil {
    fmt.Fprintln(os.Stderr, "error getting user status:", err)
    os.Exit(1)
    return
}

fmt.Fprintln(os.Stdout, "Status:", result.Status)
fmt.Fprintln(os.Stdout, "Requests sent today:", result.Requests)
fmt.Fprintln(os.Stdout, "Bytes sent today:", result.Bytes)
fmt.Fprintln(os.Stdout, "Plan:", result.Plan)
fmt.Fprintln(os.Stdout, "Plan expires:", result.PlanExpires)
fmt.Fprintln(os.Stdout, "Daily requests limit:", result.DailyRequestsLimit)
fmt.Fprintln(os.Stdout, "Daily bytes limit:", result.DailyBytesLimit)
fmt.Fprintln(os.Stdout, "Date:", result.Date)

Getting list supported languages

languages, err := client.Languages()

if err != nil {
    fmt.Fprintln(os.Stderr, "error getting languages list:", err)
    os.Exit(1)
    return
}

fmt.Fprintln(os.Stdout, "Supported languages:", len(languages))
fmt.Fprintln(os.Stdout, "First language code:", languages[0].Code)
fmt.Fprintln(os.Stdout, "First language name:", languages[0].Name)

License

Detect Language API Go Client is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.

Similar Resources

Database security suite. Database proxy with field-level encryption, search through encrypted data, SQL injections prevention, intrusion detection, honeypots. Supports client-side and proxy-side ("transparent") encryption. SQL, NoSQL.

Database security suite. Database proxy with field-level encryption, search through encrypted data, SQL injections prevention, intrusion detection, honeypots. Supports client-side and proxy-side (

Database protection suite with field level encryption and intrusion detection. | Acra Engineering Examples | Documentation | Installation | Examples a

Dec 28, 2022

Let's Encrypt client and ACME library written in Go

Let's Encrypt client and ACME library written in Go

Let's Encrypt client and ACME library written in Go. Features ACME v2 RFC 8555 Register with CA Obtain certificates, both from scratch or with an exis

Dec 27, 2022

Let's Encrypt client and ACME library written in Go

Let's Encrypt client and ACME library written in Go

Let's Encrypt client and ACME library written in Go. Features ACME v2 RFC 8555 Register with CA Obtain certificates, both from scratch or with an exis

Dec 30, 2022

End-to-end encrypted file transfer for Android. An Android Magic Wormhole client.

End-to-end encrypted file transfer for Android. An Android Magic Wormhole client.

wormhole-william-mobile This is a Magic Wormhole client for Android. (Perhaps someday this will also support iOS). Some current limitations: Receiving

Jan 4, 2023

coyim - a safe and secure chat client

coyim - a safe and secure chat client

CoyIM - a safe and secure chat client CoyIM is a new client for the XMPP protocol. It is built upon https://github.com/agl/xmpp-client and https://git

Dec 7, 2022

Generate client secret for Apple get token call

Generate client secret for Apple get token call A util to generate client secret used in Apple get token call. Create a config.json file with the foll

Jan 6, 2022

Stobox Securities Chain client based on the bsc fork

Stobox Securities Chain The goal of Stobox Securities Chain is to bring programmability and interoperability to Binance Chain. In order to embrace the

Dec 24, 2021

Stobox Securities Chain client based on the bsc fork

Stobox Securities Chain The goal of Stobox Securities Chain is to bring programmability and interoperability to Binance Chain. In order to embrace the

Dec 24, 2021

Proto-find is a tool for researchers that lets you find client side prototype pollution vulnerability.

proto-find proto-find is a tool for researchers that lets you find client side prototype pollution vulnerability. How it works proto-find open URL in

Dec 6, 2022
WhiteSource Log4j Detect is a free CLI tool that quickly scans your projects to find vulnerable Log4j versions

Log4jDetect WhiteSource Log4j Detect is a free CLI tool that quickly scans your projects to find vulnerable Log4j versions containing the following kn

Nov 20, 2022
Application trying to detect processes vulnerable to log4j JNDI exploit

Log4j JNDI Jar Detector Purpose This application is able to detect jars used by

Jan 25, 2022
Detect and fix log4j log4shell vulnerability (CVE-2021-44228)

log4fix This tool is to detect and fix the log4j log4shell vulnerability (CVE-2021-44228) by looking and removing the JndiLookup class from .jar/.war/

Sep 22, 2022
This is simple repositry use to detect which port is open. It is a custom tool built in GO LANG.

dynamic-port-scanning-in-GO-lang This is simple repositry use to detect which port is open. It is a custom tool built in GO LANG. This is CUSTOM tool

Jan 25, 2022
CLI client (and Golang module) for deps.dev API. Free access to dependencies, licenses, advisories, and other critical health and security signals for open source package versions.
CLI client (and Golang module) for deps.dev API. Free access to dependencies, licenses, advisories, and other critical health and security signals for open source package versions.

depsdev CLI client (and Golang module) for deps.dev API. Free access to dependencies, licenses, advisories, and other critical health and security sig

May 11, 2023
Sqreen's Application Security Management for the Go language
Sqreen's Application Security Management for the Go language

Sqreen's Application Security Management for Go After performance monitoring (APM), error and log monitoring it’s time to add a security component int

Dec 27, 2022
Agent-less vulnerability scanner for Linux, FreeBSD, Container, WordPress, Programming language libraries, Network devices
Agent-less vulnerability scanner for Linux, FreeBSD, Container, WordPress, Programming language libraries, Network devices

Vuls: VULnerability Scanner Vulnerability scanner for Linux/FreeBSD, agent-less, written in Go. We have a slack team. Join slack team Twitter: @vuls_e

Jan 9, 2023
A Go language implementation of the proposed ads.cert protocols for integration in programmatic ads solutions.

go-adscert A Go language implementation of the proposed ads.cert protocols for integration in programmatic ads solutions. This repository is a work-in

Jun 4, 2021
Based on user32.dll, go language is implemented to call function MessageBoxW of Windows platform
Based on user32.dll, go language is implemented to call function MessageBoxW of Windows platform

go-mbw 一个通过user32.dll调用 Windows 平台的MessageBoxW函数的 Go 语言库 A Go lib for call windows platform function MessageBoxW from user32.dll. 安装(Install) go get g

Oct 27, 2022
ARP spoofing tool based on go language, supports LAN host scanning, ARP poisoning, man-in-the-middle attack, sensitive information sniffing, HTTP packet sniffing
ARP spoofing tool based on go language, supports LAN host scanning, ARP poisoning, man-in-the-middle attack, sensitive information sniffing, HTTP packet sniffing

[ARP Spoofing] [Usage] Commands: clear clear the screen cut 通过ARP欺骗切断局域网内某台主机的网络 exit exit the program help display help hosts 主机管理功能 loot 查看嗅探到的敏感信息

Dec 30, 2022