pos

package
v0.60.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Overview

Package pos model data The data from https://github.com/fxsjy/jieba

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dict

type Dict struct {
	// contains filtered or unexported fields
}

Dict represents a dictionary used for word segmentation.

func (*Dict) AddToken

func (d *Dict) AddToken(text string, frequency float64, pos ...string)

AddToken adds one token

func (*Dict) Frequency

func (d *Dict) Frequency(key string) (float64, bool)

Frequency returns the frequency and existence of give word

func (*Dict) Pos

func (d *Dict) Pos(key string) (string, bool)

Pos returns the POS and existence of give word

type SegPos

type SegPos struct {
	Text, Pos string
}

SegPos represents a word with it's POS

type Segmenter

type Segmenter struct {
	// contains filtered or unexported fields
}

Segmenter is a words segmentation struct.

func (*Segmenter) Cut

func (seg *Segmenter) Cut(sentence string, hmm bool) (result []SegPos)

Cut cuts a sentence into words. Parameter hmm controls whether to use the HMM.

func (*Segmenter) LoadDict

func (seg *Segmenter) LoadDict(fileName ...string) error

LoadDict loads dictionary from given file name.

func (*Segmenter) Trim

func (seg *Segmenter) Trim(se []SegPos) (re []SegPos)

Trim not space and punct

func (*Segmenter) TrimPos

func (seg *Segmenter) TrimPos(se []SegPos, pos ...string) (re []SegPos)

TrimPos trim some pos

func (*Segmenter) WithGse

func (seg *Segmenter) WithGse(segs gse.Segmenter)

WithGse register gse segmenter

Jump to

Keyboard shortcuts

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