Go port of the popular Bengali phonetic-typing software Avro Phonetic
.
website
go-avro-phonetic
provides a go
package which includes a text parser
that converts Bangla written in Roman script to its phonetic
equivalent in Bangla. It implements the Avro Phonetic Dictionary
Search Library by Mehdi Hasan Khan.
In addition this library provides a cli to parse text file or text via console.
This package is inspired from Rifat Nabi's jsAvroPhonetic.
So far, the code is a go port of jsAvroPhonetic
.
And acknowledges Kaustav Das Modak for pyAvroPhonetic.
$ go get -u -v github.com/sadlil/go-avro-phonetic/...
Import the library as
import (
avro "github.com/sadlil/go-avro-phonetic"
)
With Built in Rules:
// Parse() tries to parse the given string
// In case of failure it returns an erros
text, err := avro.Parse("ami banglay gan gai")
if err != nil {
// Handle error
}
fmt.Println(test) // আমি বাংলায় গান গাই
// MustParse() tries to parse the given string
// In case of failure it panics
text := avro.MustParse("ami banglay gan gai")
fmt.Println(text) // আমি বাংলায় গান গাই
With Custom Rules:
avro.ParseWith()
receives an plugable Dictionary
interface{}
to support
custom parsing.
data.LoadJSON()
provides support for overloading custom dictionary from JSON,
which can be used for custom parsing.
customDictonary := []byte("custom dictonary json")
dict, err := data.LoadJSON(customDictonary)
if err == nil {
text := avro.ParseWith(dict, "ami banglay gan gai")
fmt.Println(text) // custom parsed text
}
Avro command line interface to parse data using command line.
$ go get -u -v github.com/sadlil/go-avro-phonetic/avrocli
$ go install github.com/sadlil/go-avro-phonetic/avrocli
Parse a test:
$ avrocli parse ami banglay gan gai
আমি বাংলায় গান গাই # this could need font support for cli.
Parse a file:
$ avrocli parse -f my_bangla.txt # this will create a my_bangla.bn.txt file
# in the same directory as the given file
# with parsed bangla texts.
- Mehdi Hasan Khan for originally developing and maintaining Avro Phonetic,
- Rifat Nabi for porting it to Javascript,
- Sarim Khan for writing ibus-avro.
Licensed under MIT Licence.