BudouX-Go is a golang port of BudouX (machine learning powered line break organizer tool).
Note: This project contains the deliverables of the BudouX project.
Note: BudouX-Go supported plain text only, not supports html inputs.
https://sg0hsmt.github.io/budoux-go/
https://go.dev/play/p/PWcZH3eULL6
Go 1.11 or later.
Import budoux and models.
import (
"github.com/sg0hsmt/budoux-go"
"github.com/sg0hsmt/budoux-go/models"
)
Split sentences with internal model.
func Example() {
model := models.DefaultJapaneseModel()
words := budoux.Parse(model, "これはテストです。")
fmt.Printf("%q", words)
// Output:
// ["これは" "テストです。"]
}
Load model from json file and split sentences using the loaded model.
func Example() {
var model budoux.Model
// You can use your own custom model.
buf, err := ioutil.ReadFile(path_to_json)
if err != nil {
log.Fatalln("read model:", err)
}
if err := json.Unmarshal(buf, &model); err != nil {
log.Fatalln("unmarshal model:", err)
}
words := budoux.Parse(model, "これはテストです。")
fmt.Printf("%q", words)
// Output:
// ["これは" "テストです。"]
}
go test ./...
You can use GitHub Actions locally by act.
act -j test
go generate ./...
Note: Generate model is require Go 1.13 or later.