Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexsergivan/transliterator
Golang text Transliterator (i.e München -> Muenchen)
https://github.com/alexsergivan/transliterator
ascii go golang normalization romanization transliteration transliterator unidecode
Last synced: about 2 months ago
JSON representation
Golang text Transliterator (i.e München -> Muenchen)
- Host: GitHub
- URL: https://github.com/alexsergivan/transliterator
- Owner: alexsergivan
- License: mit
- Created: 2020-04-17T14:19:55.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-05T12:34:35.000Z (6 months ago)
- Last Synced: 2024-07-31T20:52:34.222Z (4 months ago)
- Topics: ascii, go, golang, normalization, romanization, transliteration, transliterator, unidecode
- Language: Go
- Homepage:
- Size: 225 KB
- Stars: 41
- Watchers: 2
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - transliterator - Provides one-way string transliteration with supporting of language-specific transliteration rules. (Natural Language Processing / Transliteration)
- zero-alloc-awesome-go - transliterator - Provides one-way string transliteration with supporting of language-specific transliteration rules. (Natural Language Processing / Transliteration)
- awesome-golang-repositories - transliterator - > Muenchen) (Repositories)
- awesome-go-extra - transliterator - > Muenchen)|24|8|1|2020-04-17T14:19:55Z|2020-05-08T16:48:36Z| (Bot Building / Transliteration)
README
Golang text Transliterator
==============[![Build Status](https://travis-ci.com/alexsergivan/transliterator.svg?branch=master)](https://travis-ci.com/github/alexsergivan/transliterator)
[![Coverage Status](https://coveralls.io/repos/github/alexsergivan/transliterator/badge.svg)](https://coveralls.io/github/alexsergivan/transliterator)
[![Go Report Card](https://goreportcard.com/badge/github.com/alexsergivan/transliterator)](https://goreportcard.com/report/github.com/alexsergivan/transliterator)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9b062cd8ba9f4f7f850e167d6966b75b)](https://www.codacy.com/manual/alexsergivan/transliterator?utm_source=github.com&utm_medium=referral&utm_content=alexsergivan/transliterator&utm_campaign=Badge_Grade)Golang Transliterator provides one-way string transliteration. It takes Unicode text and converts to ASCII characters.
Example use-case: transliterate cyrilic city name to be able to use it in the url ("Київ" ==> "Куiv").For now, only these languages have specific transliteration rules: DE, DA, EO, RU, BG, SV, HU, HR, SL, SR, NB, UK, MK, CA, BS. For other languages, general ASCII transliteration rules will be applied. Also, this package supports adding custom transliteration rules for your specific use-case. Please check the examples section below.
Installation
------------```
go get -u github.com/alexsergivan/transliterator
```Language specific transliteration example
------```go
package mainimport (
"fmt"
"github.com/alexsergivan/transliterator"
)func main() {
trans := transliterator.NewTransliterator(nil)
text := "München"
// Langcode should be provided accrding to ISO 639-1.
fmt.Println(trans.Transliterate(text, "de")) // Result: Muenchen
fmt.Println(trans.Transliterate(text, "en")) // Result: MunchenanotherText := "你好"
fmt.Println(trans.Transliterate(anotherText, "")) // Result: Ni HaooneMoreText := "Київ"
fmt.Println(trans.Transliterate(oneMoreText, "uk")) // Result: Kyiv
fmt.Println(trans.Transliterate(oneMoreText, "en")) // Result: Kiyiv
fmt.Println(trans.Transliterate(oneMoreText, "")) // Result: Kiyiv
}
```Adding of custom Language translitartion rules
------```go
package mainimport (
"fmt"
"github.com/alexsergivan/transliterator"
)func main() {
customLanguageOverrites := make(map[string]map[rune]string)customLanguageOverrites["myLangcode"] = map[rune]string{
// Ї
0x407: "CU",
// и
0x438: "y",
}
trans := transliterator.NewTransliterator(&customLanguageOverrites)
text := "КиЇв"
fmt.Println(trans.Transliterate(text, "myLangcode")) // Result: KyCUv}
```