An open API service indexing awesome lists of open source software.

https://github.com/mdm-code/prg2p

Grapheme-to-phoneme rule-based converter for Polish in Go.
https://github.com/mdm-code/prg2p

cli converter filter g2p go golang golang-package grapheme-to-phoneme natural-language-processing nlp nlproc tui

Last synced: 5 months ago
JSON representation

Grapheme-to-phoneme rule-based converter for Polish in Go.

Awesome Lists containing this project

README

          



logo

Grapheme-to-phoneme converter for Polish in Go




Build status


Code coverage


MIT license


Go report card


Go package docs


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](https://pkg.go.dev/github.com/mdm-code/prg2p)
or check [Usage](#usage) section below to see how to use `prg2p` in your code.

## Installation

To add package to a Go project dependencies run the following command:

```sh
go get github.com/mdm-code/prg2p
```

In order to use the CLI program, you need to use this command:

```sh
go install github.com/mdm-code/prg2p@latest
```

Here, you can use the `@latest` or any version you find appropriate for that
matter.

## Usage

Type `prg2p -h` from the terminal after installing executables as described
[here](#installation) 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:

```go
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)
}
}
```

## Development

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:

```sh
go install golang.org/x/lint/golint@latest
```

Happy coding!

## License

Copyright (c) 2023 Michał Adamczyk.

This project is licensed under the [MIT license](https://opensource.org/licenses/MIT).
See [LICENSE](LICENSE) for more details.