Documentation ¶
Index ¶
- Constants
- type AccPool
- type Dict
- type DictAcceptor
- type DictEdgeBuilder
- type Edge
- type EdgeBuilder
- type EdgeBuildingContext
- type Etype
- type Index
- type PatEdgeBuilder
- type Policy
- type PrefixTree
- type PrefixTreeNode
- type PrefixTreePointer
- type TextRange
- type UnkEdgeBuilder
- type WordWithPayload
- type Wordcut
Constants ¶
const ( DICT Etype = 1 UNK = 2 INIT = 3 LATIN = 4 SPACE = 5 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccPool ¶
type AccPool struct {
// contains filtered or unexported fields
}
AccPool - pool of dict acceptor
func (*AccPool) Obtain ¶
func (pool *AccPool) Obtain(p int) *DictAcceptor
Obtain - obtain dict acceptor at p
type Dict ¶
type Dict struct {
// contains filtered or unexported fields
}
Dict is a prefix tree
func LoadDefaultDict ¶
LoadDefaultDict - loading default Thai dictionary
type DictAcceptor ¶
type DictAcceptor struct {
// contains filtered or unexported fields
}
func (*DictAcceptor) Transit ¶
func (a *DictAcceptor) Transit(ch rune, dict *Dict)
Transit - walk on prefix tree by new rune
type DictEdgeBuilder ¶
type DictEdgeBuilder struct {
// contains filtered or unexported fields
}
func NewDictEdgeBuilder ¶
func NewDictEdgeBuilder(dict *Dict) *DictEdgeBuilder
func (*DictEdgeBuilder) Build ¶
func (builder *DictEdgeBuilder) Build(context *EdgeBuildingContext) *Edge
Build - build new edge from dictionary
func (*DictEdgeBuilder) Reset ¶
func (builder *DictEdgeBuilder) Reset()
type Edge ¶
Edge - edge of word graph
func (*Edge) IsBetterThan ¶
IsBetterThan - comparing this edge to another edge
type EdgeBuilder ¶
type EdgeBuilder interface { Build(*EdgeBuildingContext) *Edge Reset() }
type EdgeBuildingContext ¶
type PatEdgeBuilder ¶
type PatEdgeBuilder struct {
// contains filtered or unexported fields
}
func (*PatEdgeBuilder) Build ¶
func (builder *PatEdgeBuilder) Build(context *EdgeBuildingContext) *Edge
func (*PatEdgeBuilder) Reset ¶
func (builder *PatEdgeBuilder) Reset()
type PrefixTree ¶
type PrefixTree struct {
// contains filtered or unexported fields
}
PrefixTree is a Hash-based Prefix Tree for searching words
func MakePrefixTree ¶
func MakePrefixTree(wordsWithPayload []WordWithPayload) *PrefixTree
MakePrefixTree is for constructing prefix tree for word with payload list
func (*PrefixTree) Lookup ¶
func (tree *PrefixTree) Lookup(nodeID int, offset int, ch rune) (*PrefixTreePointer, bool)
Lookup - look up prefix tree from node-id, offset and a character
type PrefixTreeNode ¶
PrefixTreeNode represents node in a prefix tree
type PrefixTreePointer ¶
PrefixTreePointer is partial information of edge
type TextRange ¶
type TextRange struct {
// contains filtered or unexported fields
}
func GraphToRanges ¶
Improved as Roger Peppe suggested in his tweet https://twitter.com/rogpeppe/status/574911374645682176
type UnkEdgeBuilder ¶
type UnkEdgeBuilder struct { }
func (*UnkEdgeBuilder) Build ¶
func (builder *UnkEdgeBuilder) Build(context *EdgeBuildingContext) *Edge
Build - build dummy edge when there is no edge created.
func (*UnkEdgeBuilder) Reset ¶
func (builder *UnkEdgeBuilder) Reset()
type WordWithPayload ¶
type WordWithPayload struct { Word string Payload interface{} }
WordWithPayload is a pair of word and its payload