words

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPunctuation = []rune{
		',', ',', '.', '。', ':', ':', ';', ';', '[', ']', '【', ']', '】', '{', '{', '}', '}',
		'(', '(', ')', ')', '<', '《', '>', '》', '$', '¥', '!', '!', '?', '?', '~', '~',
		'\'', '’', '"', '“', '”',
		'*', '/', '\\', '&', '%', '@', '#', '^', '、', '、', '、', '、',
	}

	RxSpaces   = regexp.MustCompile(`\s+`)
	RxSymbols  = regexp.MustCompile(`\p{S}`)
	RxCharSets = regexp.MustCompile(`[\p{Han}\p{Katakana}\p{Hiragana}\p{Hangul}]`)
)

Functions

func Count

func Count(input string, cfg *Config) (count int)

func List

func List(input string, cfg *Config) (list []string)

func Parse

func Parse(input string, cfg *Config) (words []string)

func Range

func Range(input string, cfg *Config, fn func(word string))
func Search(query, content string, cfg *Config) (score int, present []string)

Types

type Config

type Config struct {
	PunctuationAsBreaker      bool
	DisableDefaultPunctuation bool
	Punctuation               []rune
}

func DefaultConfig

func DefaultConfig() (cfg *Config)

func (*Config) Count

func (cfg *Config) Count(input string) (count int)

func (*Config) List

func (cfg *Config) List(input string) (list []string)

func (*Config) Parse

func (cfg *Config) Parse(input string) (words []string)

func (*Config) Range

func (cfg *Config) Range(input string, fn func(word string))

func (*Config) Search

func (cfg *Config) Search(query, content string) (score int, found []string)

Jump to

Keyboard shortcuts

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