gothaiwordcut

package module
v0.0.0-...-67244db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 7 Imported by: 0

README

go-thaiwordcut - Thai word segmentation in Golang

Codacy Badge

A simple Thai word segmentation written in Golang, based on Maximum Matching algorithm by S. Manabu . Uses Lexitron (by NECTEC) dictionary as default

Installation

go get github.com/WavePakawut/go-thaiwordcut

Usage

import "github.com/WavePakawut/go-thaiwordcut"

segmenter := gothaiwordcut.Wordcut()
segmenter.LoadDefaultDict()
result := segmenter.Segment("ทดสอบการตัดคำภาษาไทย")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Segmenter)

Option : Option for Segmenter

type Segmenter

type Segmenter struct {
	Tree *radix.Tree
	// contains filtered or unexported fields
}

Segmenter : Segmenter main class

func Wordcut

func Wordcut(options ...Option) *Segmenter

Wordcut : main wordcut function

func (*Segmenter) LoadDefaultDict

func (w *Segmenter) LoadDefaultDict(customPath string) error

LoadDefaultDict : load dictionary into trie

func (w *Segmenter) LoadDefaultDict() {
	_, filename, _, _ := runtime.Caller(0)
	w.loadFileIntoTrie(path.Dir(filename) + "/dict/lexitron.txt")
}

func (*Segmenter) Segment

func (w *Segmenter) Segment(txt string) []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL