txt

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GoMono      = gomono.TTF
	GoRegular   = goregular.TTF
	Inconsolata = inconsolata.Regular8x16
	DefaultFont = inconsolata.Regular8x16
)
View Source
var (
	FieldsFuncErr = errors.New("strings.FieldsFunc returned an empty slice or the string was empty")
	EmptyStrErr   = errors.New("empty string")
	NoMatchErr    = errors.New(`no matches found`)
)

Functions

func DefaultStopWords

func DefaultStopWords() []string

func NewPaginator added in v0.0.5

func NewPaginator(txt string, opts ...WrapOpt) *pages.Pages[string]

func NewTTF added in v0.0.5

func NewTTF(src []byte, opts *opentype.FaceOptions) (font.Face, error)

func NoopNormalizer added in v0.0.5

func NoopNormalizer(str string) string

func PaginateText added in v0.0.5

func PaginateText(txt string, w int, maxLines int) *pages.Pages[string]

func PaginateTextbox added in v0.0.5

func PaginateTextbox(txt string, w, h int, opts ...WrapOpt) *pages.Pages[string]

func SimpleWrap added in v0.0.5

func SimpleWrap(txt string, w, maxLines int) ([]string, int)

func SortByAlphaFunc added in v0.0.2

func SortByAlphaFunc(a *Token, b *Token) int

func Split added in v0.0.2

func Split(str string, s sep.Func) []string

func Stem

func Stem(token string) string

func StripPunct

func StripPunct(token string) string

func ToLower

func ToLower(ana *Analyzer)

func WithDefaultStopWords

func WithDefaultStopWords(ana *Analyzer)

func WithStemmer

func WithStemmer(ana *Analyzer)

func WithoutPunct

func WithoutPunct(ana *Analyzer)

func WrapFont added in v0.0.5

func WrapFont(txt string, opts ...WrapOpt) ([]string, int)

func WrapTextbox added in v0.0.5

func WrapTextbox(txt string, w, h int, opts ...WrapOpt) ([]string, int)

Types

type AllTokens added in v0.0.5

type AllTokens []*Token

func Normalize

func Normalize(ls []string, normies []Normalizer) AllTokens

func (AllTokens) Find added in v0.0.5

func (toks AllTokens) Find(q string) (AllTokens, error)

func (AllTokens) FindByIndex added in v0.0.5

func (toks AllTokens) FindByIndex(ti []int) (AllTokens, error)

func (AllTokens) FindByLabel added in v0.0.5

func (toks AllTokens) FindByLabel(label string) (*Token, error)

func (AllTokens) FindByValue added in v0.0.5

func (toks AllTokens) FindByValue(val string) (*Token, error)

func (AllTokens) Labels added in v0.0.5

func (toks AllTokens) Labels() []string

func (AllTokens) Len added in v0.0.5

func (toks AllTokens) Len() int

func (AllTokens) Search added in v0.0.5

func (toks AllTokens) Search(q string) (AllTokens, error)

func (AllTokens) Sort added in v0.0.5

func (toks AllTokens) Sort(cmp func(a, b *Token) int, order string) AllTokens

func (AllTokens) SortAlphaAsc added in v0.0.5

func (toks AllTokens) SortAlphaAsc() AllTokens

func (AllTokens) SortAlphaDesc added in v0.0.5

func (toks AllTokens) SortAlphaDesc() AllTokens

func (AllTokens) SortStable added in v0.0.5

func (toks AllTokens) SortStable(cmp func(a, b *Token) int, order string) AllTokens

func (AllTokens) String added in v0.0.5

func (toks AllTokens) String(i int) string

func (AllTokens) Values added in v0.0.5

func (toks AllTokens) Values() []string

func (AllTokens) Without added in v0.0.5

func (toks AllTokens) Without(sw AllTokens) AllTokens

type Analyzer

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

func Keywords

func Keywords() *Analyzer

func New

func New(opts ...Option) *Analyzer

func NewNormalizer added in v0.0.2

func NewNormalizer(opts ...Option) *Analyzer

func (*Analyzer) AddNormalizer

func (ana *Analyzer) AddNormalizer(normies ...Normalizer) *Analyzer

func (*Analyzer) IsStopWord

func (ana *Analyzer) IsStopWord(token string) bool

func (*Analyzer) Keywords

func (ana *Analyzer) Keywords() *Analyzer

func (*Analyzer) SetStopWords

func (ana *Analyzer) SetStopWords(words []string) *Analyzer

func (*Analyzer) Stopwords added in v0.0.2

func (ana *Analyzer) Stopwords() AllTokens

func (*Analyzer) Tokenize

func (ana *Analyzer) Tokenize(text string) (AllTokens, error)

func (*Analyzer) WithNormalizer

func (ana *Analyzer) WithNormalizer(normies ...Normalizer) *Analyzer

func (*Analyzer) WithSep

func (ana *Analyzer) WithSep(sep sep.Func) *Analyzer

func (*Analyzer) WithoutStopWords added in v0.0.4

func (ana *Analyzer) WithoutStopWords() bool

type Normalizer

type Normalizer func(string) string

type Option

type Option func(*Analyzer)

func WithNormalizers

func WithNormalizers(n ...Normalizer) Option

func WithStopWords

func WithStopWords(words []string) Option

type Token

type Token struct {
	Value string `json:"value"`
	Label string `json:"label"`
	fuzzy.Match
}

func NewToken

func NewToken(label, val string) *Token

type Tokens

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

func NewTokens added in v0.0.5

func NewTokens() *Tokens

func (*Tokens) AddString added in v0.0.5

func (t *Tokens) AddString(str string) *Tokens

func (*Tokens) AddToken added in v0.0.5

func (t *Tokens) AddToken(tok *Token) *Tokens

func (*Tokens) SetStringSlice added in v0.0.5

func (t *Tokens) SetStringSlice(str []string) *Tokens

func (*Tokens) SetTokens added in v0.0.5

func (t *Tokens) SetTokens(toks []*Token) *Tokens

type WrapOpt added in v0.0.5

type WrapOpt func(w *Wrapper)

func WithFont added in v0.0.5

func WithFont(face font.Face) WrapOpt

func WithGoMono added in v0.0.5

func WithGoMono(fs int) WrapOpt

func WithGoRegular added in v0.0.5

func WithGoRegular(fs int) WrapOpt

func WithMaxLines added in v0.0.5

func WithMaxLines(maxLines int) WrapOpt

func WithSize added in v0.0.5

func WithSize(w, h int) WrapOpt

type Wrapper added in v0.0.5

type Wrapper struct {
	FontSize   int
	Width      int
	DPI        int
	MaxLines   int
	Height     int
	LineHeight int
	Font       font.Face
	Simple     bool
}

func NewWrapper added in v0.0.5

func NewWrapper(opts ...WrapOpt) *Wrapper

func (*Wrapper) LinesPerPage added in v0.0.5

func (pg *Wrapper) LinesPerPage() int

func (*Wrapper) Paginate added in v0.0.5

func (wr *Wrapper) Paginate(txt string) *pages.Pages[string]

func (*Wrapper) SetFont added in v0.0.5

func (wr *Wrapper) SetFont(face font.Face) *Wrapper

func (*Wrapper) SetFontSize added in v0.0.5

func (wr *Wrapper) SetFontSize(fs int) *Wrapper

func (*Wrapper) SetHeight added in v0.0.5

func (pg *Wrapper) SetHeight(m int) *Wrapper

func (*Wrapper) SetLineHeight added in v0.0.5

func (pg *Wrapper) SetLineHeight(m int) *Wrapper

func (*Wrapper) SetMaxLines added in v0.0.5

func (pg *Wrapper) SetMaxLines(m int) *Wrapper

func (*Wrapper) SetSize added in v0.0.5

func (wr *Wrapper) SetSize(w, h int) *Wrapper

func (*Wrapper) SetWidth added in v0.0.5

func (wr *Wrapper) SetWidth(w int) *Wrapper

func (*Wrapper) WithTTF added in v0.0.5

func (wr *Wrapper) WithTTF(src []byte, fs int) error

func (*Wrapper) WrapText added in v0.0.5

func (wr *Wrapper) WrapText(str string) []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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