model

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToStrings

func ToStrings(items []*Tag) []string

ToStrings transforms list of given tags into a list of strings.

Types

type InputReader

type InputReader interface {
	ReadLines() ([]string, error)
	io.ReadCloser
}

InputReader ...

type Meta

type Meta struct {
	ContentType config.ContentType
	DocTitle    string
	DocHash     string
	Lang        string
	Screenshot  []byte // bytes of the viewport screenshot in png
}

Meta extra information.

type ProcessFunc added in v0.56.0

type ProcessFunc func(c *config.Config, reader io.ReadCloser) *Result

ProcessFunc represents an arbitrary handler, which goes through given reader and produces tags.

type Result

type Result struct {
	Meta       *Meta
	RawTags    map[string]*Tag
	Tags       []*Tag // processed slice of the result dictionary - RawTags
	Extensions map[string]map[string]*extension.ExtResult
	Err        error
}

Result represents result of Tagify.

func EmptyResult

func EmptyResult() *Result

func ErrResult

func ErrResult(err error) *Result

func (*Result) FindExtResults

func (res *Result) FindExtResults(name, version string) []*extension.ExtResult

FindExtResults finds requested extension result(s), in case if version is empty.

func (*Result) Flatten

func (res *Result) Flatten() []*Tag

FlatTags transforms internal token register into a slice.

func (*Result) ForEach

func (r *Result) ForEach(fn func(i int, tag *Tag))

ForEach iterates through the slice of Tags and calls provided "fn" on every iteration.

func (*Result) Len

func (r *Result) Len() int

Len returns count of the processed (if any) tags in the result.

func (*Result) RawLen

func (r *Result) RawLen() int

RawLen returns count of the all (found) tags in the result.

func (*Result) TagsStrings

func (r *Result) TagsStrings() []string

TagsStrings returns slice of strings representing tags.

type Tag

type Tag struct {
	// Value of the tag, i.e. a word
	Value string
	// Score used to represent importance of the tag
	Score float64
	// Count is the number of times tag appeared in a text
	Count int
	// Docs is the number of documents in a text in which the tag appeared
	Docs int
	// DocsCount is the number of documents in a text
	DocsCount int
}

Tag holds some arbitrary string value (e.g. a word) along with some extra data about it.

func (*Tag) String

func (t *Tag) String() string

Jump to

Keyboard shortcuts

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