segment

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

README

README

注册驱动

import (
	_ "github.com/admpub/webx/application/library/search/segment/gojieba"
	_ "github.com/admpub/webx/application/library/search/segment/jiebago"
    _ "github.com/admpub/webx/application/library/search/segment/sego"
)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultEngine = `sego` // gojieba / sego / jiebago

	Filters []Filter
)
View Source
var (

	// DictFile 分词词典文件
	DictFile string
)

Functions

func AddFilter

func AddFilter(filter Filter)

func CleanStopWords

func CleanStopWords(v string) string

func CleanStopWordsFromSlice

func CleanStopWordsFromSlice(v []string) (r []string)

func DoFilter

func DoFilter(v string) bool

func Has

func Has(name string) bool

func IsInitialized

func IsInitialized() bool

func IsNop

func IsNop(segment Segment) bool

func LoadStopWordsDict

func LoadStopWordsDict(stopWordsFile string, args ...bool)

func Register

func Register(name string, c func() Segment)

func ReloadDict

func ReloadDict(dictFiles ...string) error

ReloadDict 重新加载词典

func ResetSegment

func ResetSegment()

func ResetStopwords

func ResetStopwords()

func SplitWords

func SplitWords(b []byte, args ...string) []string

SplitWords 分词

func SplitWordsAsString

func SplitWordsAsString(b []byte, args ...string) string

SplitWordsAsString 将分词结果作为字串返回

func SplitWordsBy

func SplitWordsBy(b []byte, mode string, args ...string) []string

SplitWordsBy 按模式分词

func StopWords

func StopWords() []string

func Unregister

func Unregister(name string)

Types

type Filter

type Filter func(string) bool

type Segment

type Segment interface {
	//载入词典(词典路径,词典类型)
	LoadDict(string, ...string) error

	//分词(文本,词性)
	Segment(string, ...string) []string

	//分词(文本,分词模式,词性)
	SegmentBy(string, string, ...string) []string

	//关闭或释放资源
	Close() error
}

Segment interface

func Default

func Default() Segment

func Get

func Get(name string) Segment

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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