The prg2p
package implements a grapheme-to-phoneme rule based converter for
Polish.
It provides a standalone command-line program to process data efficiently on the terminal and exposes the public API components of the package for code reuse.
Consult the package documentation
or check Usage section below to see how to use prg2p
in your code.
To add package to a Go project dependencies run the following command:
go get github.com/mdm-code/prg2p
In order to use the CLI program, you need to use this command:
go install github.com/mdm-code/prg2p@latest
Here, you can use the @latest
or any version you find appropriate for that
matter.
Type prg2p -h
from the terminal after installing executables as described
here to see how to use prg2p
command-line interface.
Here is how you can use the public API of the prg2p
package in your code:
package main
import (
"fmt"
"github.com/mdm-code/prg2p"
)
func main() {
r := prg2p.Rules()
g2p, err := prg2p.Load(r)
if err != nil {
fmt.Println(err)
return
}
// Iterate over words to get their phonemic transcripts
var trans []string
for _, w := range []string{"ala", "ma", "kota"} {
t, err := g2p.Transcribe(w, false)
if err != nil {
fmt.Println(err)
continue
}
trans = append(trans, t...)
}
for _, t := range trans {
fmt.Println(t)
}
}
All necessary development tools are in the Makefile
. Calling make test
consecutively invokes go fmt
, go vet
, golint
and go test
. CI/CD is
handled by Github workflows. Remember to install golint
before testing and
building:
go install golang.org/x/lint/golint@latest
Happy coding!
Copyright (c) 2023 Michał Adamczyk.
This project is licensed under the MIT license. See LICENSE for more details.