lattice

package
v2.9.7 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package lattice implements the core of the morph analyzer.

Index

Constants

View Source
const BosEosID int = -1

BosEosID represents Reserved identifier of node id.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lattice

type Lattice struct {
	Input  string
	Output []*Node
	// contains filtered or unexported fields
}

Lattice represents a grid of morph nodes.

func New

func New(d *dict.Dict, u *dict.UserDict) *Lattice

New returns a new lattice.

func (*Lattice) Backward

func (la *Lattice) Backward(m TokenizeMode)

Backward runs backward algorithm of the Viterbi.

func (*Lattice) Build

func (la *Lattice) Build(inp string)

Build builds a lattice from the inputs. nolint: gocyclo

func (*Lattice) Dot

func (la *Lattice) Dot(w io.Writer)

Dot outputs a lattice in the graphviz dot format.

func (*Lattice) Forward

func (la *Lattice) Forward(m TokenizeMode)

Forward runs forward algorithm of the Viterbi.

func (*Lattice) Free

func (la *Lattice) Free()

Free releases a memory of a lattice.

func (*Lattice) String

func (la *Lattice) String() string

String returns a debug string of a lattice.

type Node added in v2.8.0

type Node struct {
	ID       int
	Position int // byte position
	Start    int // rune position
	Class    NodeClass
	Cost     int32
	Left     int32
	Right    int32
	Weight   int32
	Surface  string
	// contains filtered or unexported fields
}

Node is a lattice node.

type NodeClass

type NodeClass int

NodeClass represents a node type.

const (
	DUMMY NodeClass = iota
	KNOWN
	UNKNOWN
	USER
)

NodeClass codes.

func (NodeClass) String

func (nc NodeClass) String() string

String returns a string representation of a node class.

type TokenizeMode

type TokenizeMode int

TokenizeMode represents how to tokenize sentence.

const (
	// Normal Mode
	Normal TokenizeMode = iota + 1
	// Search Mode
	Search
	// Extended Mode
	Extended
)

Directories

Path Synopsis
Package mem implements the memory utility such as memory pool.
Package mem implements the memory utility such as memory pool.

Jump to

Keyboard shortcuts

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