util

package
v0.0.0-...-0906917 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(s string) uint32

func IsTerminal

func IsTerminal(file *os.File) bool

Types

type Article

type Article struct {
	Title string
	Text  []interface{}
}

func (*Article) Append

func (a *Article) Append(v interface{})

func (*Article) Prepend

func (a *Article) Prepend(v interface{})

func (*Article) StartsWithHeading

func (a *Article) StartsWithHeading() bool

type Bitset

type Bitset struct {
	Bucket uint64
}

func NewBitset

func NewBitset() *Bitset

func (*Bitset) Add

func (f *Bitset) Add(val uint32)

Adds a value to Bitset.

func (*Bitset) Cap

func (f *Bitset) Cap() int

Return the total number of buckets.

func (*Bitset) Common

func (f *Bitset) Common(g *Bitset) int

Returns the number of common elements.

func (*Bitset) Len

func (f *Bitset) Len() int

Return the number of buckets in use.

func (*Bitset) Union

func (f *Bitset) Union(g *Bitset)

Adds elements from g to Bitset.

type Heading

type Heading string

type Input

type Input struct {
	Origin string        // either file path or URL or empty if data was read from stdin
	Data   io.ReadCloser // the HTML data (hopefully)
}

Input stores the user-provided data and its origin.

func GetByUrl

func GetByUrl(url string) []Input

type Paragraph

type Paragraph string

type Regex

type Regex struct {
	*regexp.Regexp
}

func NewRegex

func NewRegex(pattern string) *Regex

NewRegex creates a new Regex struct matching the given pattern.

func NewRegexFromWords

func NewRegexFromWords(words ...string) *Regex

NewWordMatchRegex creates a new Regex struct matching any of the words passed as arguments.

func (*Regex) In

func (r *Regex) In(text string) bool

In returns true if a match can be found in text.

type Stringset

type Stringset struct {
	Bitset
}

func NewStringset

func NewStringset() *Stringset

func (*Stringset) Add

func (f *Stringset) Add(val string)

Adds a value to Stringset.

type Text

type Text struct {
	Words     int
	Sentences int
	// contains filtered or unexported fields
}

func NewText

func NewText() *Text

func (*Text) Len

func (t *Text) Len() int

func (*Text) Similarity

func (t *Text) Similarity(u *Text) float32

Calculate a word-based similarity to a given text. This function returns values between [0,1], where zero means the texts share no words and one means the text have all words in common. This function is fuzzy.

func (*Text) String

func (t *Text) String() string

func (*Text) WriteString

func (t *Text) WriteString(s string)

func (*Text) WriteText

func (t *Text) WriteText(s *Text)

Jump to

Keyboard shortcuts

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