All Projects → veer66 → mapkha

veer66 / mapkha

Licence: LGPL-3.0 license
Thai word segmentation program in Go

Programming Languages

go
31211 projects - #10 most used programming language

Mapkha

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

Example 1: Word segmentation

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()), "|"))
    }
}

Example 2: Word wrap

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.WordWrap(scanner.Text(), 30), "|"))
    }
}

Contributors

  • Vee Satayamas
  • Weerasak Chongnguluam (@iporsut)
  • Phongphan Phienphanich (@kapong)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].