Skip to content

BudouX-Go is a golang port of BudouX (machine learning powered line break organizer tool).

License

Notifications You must be signed in to change notification settings

sg0hsmt/budoux-go

Repository files navigation

BudouX-Go

Go Reference Test TinyGo Go Report Card License Release

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.

Demo

https://sg0hsmt.github.io/budoux-go/

https://go.dev/play/p/PWcZH3eULL6

Requirement

Go 1.11 or later.

Usage

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:
    // ["これは" "テストです。"]
}

Test

go test ./...

You can use GitHub Actions locally by act.

act -j test

Generate model from original BudouX

go generate ./...

Note: Generate model is require Go 1.13 or later.

About

BudouX-Go is a golang port of BudouX (machine learning powered line break organizer tool).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages