/mapkha

Thai word segmentation program in Go

Primary LanguageGoGNU Lesser General Public License v3.0LGPL-3.0

Mapkha

Thai word segmentation (wordcut; word boundary identification; ตัดคำ) program in Go (golang)

Example

package main

import ("fmt"
    "strings"
    "bufio"
    "os"
    m "github.com/veer66/mapkha"
)

func check(e error) {
    if e != nil {
        panic(e)
    }
}

func main() {
    dict, e := m.LoadDefaultDict()
    check(e)
    wordcut := m.NewWordcut(dict)
    scanner := bufio.NewScanner(os.Stdin)
    for scanner.Scan() {
        fmt.Println(strings.Join(wordcut.Segment(scanner.Text()), "|"))
    }
}