Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

lingua-go

> 开发工具
Open source

The most accurate natural language detection library for Go, suitable for short text and mixed-language text

1.4K stars0 likes1 views
WebsiteGitHub

About

The most accurate natural language detection library for Go, suitable for short text and mixed-language text


## 1. What does this library do? Its task is simple: It tells you which language some text is written in. This is very useful as a preprocessing step for linguistic data in natural language processing applications such as text classification and spell checking. Other use cases, for instance, might include routing e-mails to the right geographically located customer service department, based on the e-mails' languages. ## 2. Why does this library exist? Language detection is often done as part of large machine learning frameworks or natural language processing applications. In cases where you don't need the full-fledged functionality of those systems or don't want to learn the ropes of those, a small flexible library comes in handy. So far, the only other comprehensive open source library in the Go ecosystem for this task is [*Whatlanggo*](https://github.com/abadojack/whatlanggo). Unfortunately, it has two major drawbacks: 1. Detection only works with quite lengthy text fragments. For very short text snippets such as Twitter messages, it does not provide adequate results. 2. The more languages take part in the decision process, the less accurate are the detection results. *Lingua* aims at eliminating these problems. She nearly does not need any configuration and yields pretty accurate results on both long and short text, even on single words and phrases. She draws on both rule-based and statistical methods but does not use any dictionaries of words. She does not need a connection to any external API or service either. Once the library has been downloaded, it can be used completely offline. ## 3. Which languages are supported? Compared to other language detection libraries, *Lingua's* focus is on *quality over quantity*, that is, getting detection right for a small set of languages first before adding new ones. Currently, the following 75 languages are supported: - A - Afrikaans - Albanian - Arabic - Armenian - Azerbaijani - B - Basque - Belarusian - Bengali - Norwegian Bokmal - Bosnian - Bulgarian - C - Catalan - Chinese - Croatian - Czech - D - Danish - Dutch - E - English - Esperanto - Estonian - F - Finnish - French - G - Ganda - Georgian - German - Greek - Gujarati - H - Hebrew - Hindi - Hungarian - I - Icelandic - Indonesian - Irish - Italian - J - Japanese - K - Kazakh - Korean - L - Latin - Latvian - Lithuanian - M - Macedonian - Malay - Maori - Marathi - Mongolian - N - Norwegian Nynorsk - P - Persian - Polish - Portuguese - Punjabi - R - Romanian - Russian - S - Serbian - Shona - Slovak - Slovene - Somali - Sotho - Spanish - Swahili - Swedish - T - Tagalog - Tamil - Telugu - Thai - Tsonga - Tswana - Turkish - U - Ukrainian - Urdu - V - Vietnamese - W - Welsh - X - Xhosa - Y - Yoruba - Z - Zulu ## 4. How good is it? *Lingua* is able to report accuracy statistics for some bundled test data available for each supported language. The test data for each language is split into three parts: 1. a list of single words with a minimum length of 5 characters 2. a list of word pairs with a minimum length of 10 characters 3. a list of complete grammatical sentences of various lengths Both the language models and the test data have been created from separate documents of the [Wortschatz corpora](https://wortschatz.uni-leipzig.de) offered by Leipzig University, Germany. Data crawled from various news websites have been used for training, each corpus comprising one million sentences. For testing, corpora made of arbitrarily chosen websites have been used, each comprising ten thousand sentences. From each test corpus, a random unsorted subset of 1000 single words, 1000 word pairs and 1000 sentences has been extracted, respectively. Given the generated test data, I have compared the detection results of *Lingua* and *Whatlanggo* running over the data of *Lingua's* supported 75 languages. Additionally, I have added Google's [CLD3](https://github.com/google/cld3/) to the comparison with the help of the [gocld3](https://github.com/jmhodges/gocld3) bindings. Languages that are not supported by *CLD3* or *Whatlanggo* are simply ignored during the detection process. Each of the following sections contains two plots. The bar plot shows the detailed accuracy results for each supported language. The box plot illustrates the distributions of the accuracy values for each classifier. The boxes themselves represent the areas which the middle 50 % of data lie within. Within the colored boxes, the horizontal lines mark the median of the distributions. ### 4.1 Single word detection

Bar plot

### 4.2 Word pair detection

Bar plot

### 4.3 Sentence detection

Bar plot

### 4.4 Average detection

Bar plot

### 4.5 Mean, median and standard deviation The table below shows detailed statistics for each language and classifier including mean, median and standard deviation. Open table
Language Average Single Words Word Pairs Sentences
Lingua
(high accuracy mode)
Lingua
(low accuracy mode)
  CLD3   Whatlang Lingua
(high accuracy mode)
Lingua
(low accuracy mode)
  CLD3   Whatlang Lingua
(high accuracy mode)
Lingua
(low accuracy mode)
  CLD3   Whatlang Lingua
(high accuracy mode)
Lingua
(low accuracy mode)
  CLD3   Whatlang
Afrikaans 79 64 55 51 58 38 22 21 81 62 46 39 97 93 98 92
Albanian 88 80 55 - 69 54 18 - 95 86 48 - 100 99 98 -
Arabic 98 94 90 89 96 88 79 77 99 96 92 91 100 99 100 99
Armenian 100 100 99 - 100 100 100 - 100 100 100 - 100 100 97 -
Azerbaijani 90 82 81 64 77 71 62 45 92 78 82 58 99 96 99 91
Basque 84 75 62 - 71 56 33 - 87 76 62 - 93 92 92 -
Belarusian 97 92 84 81 92 80 67 64 99 95 86 80 100 100 100 98
Bengali 100 100 99 100 100 100 98 100 100 100 99 100 100 100 99 100
Bokmal 58 50 - 34 39 27 - 15 59 47 - 28 77 75 - 60
Bosnian 35 29 33 - 29 23 19 - 35 29 28 - 41 36 52 -
Bulgarian 87 78 70 61 70 56 45 37 91 81 66 57 99 96 98 89
Catalan 70 58 48 - 51 33 19 - 74 60 42 - 87 82 84 -
Chinese 100 100 92 100 100 100 92 100 100 100 83 100 100 100 100 100
Croatian 73 60 42 55 53 36 26 28 74 57 42 44 90 86 58 91
Czech 80 71 64 50 66 54 39 31 84 72 65 46 91 87 88 71
Danish 81 70 58 47 61 45 26 24 84 70 54 38 98 95 95 79
Dutch 77 64 58 47 55 36 29 22 81 61 47 36 96 94 97 82
English 81 63 54 49 55 29 22 17 89 62 44 35 99 97 97 94
Esperanto 84 66 57 52 67 44 22 25 85 61 51 45 98 93 98 88
Estonian 92 83 70 61 80 62 41 36 96 88 69 53 100 99 99 94
Finnish 96 91 80 71 90 7

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gogogolang-librarylanguage-classificationlanguage-detection

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具