heffalump

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT, MIT Imports: 9 Imported by: 0

Documentation

Overview

Package heffalump attempts to encapsulate the original work by carlmjohnson on heffalump https://github.com/carlmjohnson/heffalump

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScanHTML

func ScanHTML(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanHTML is a basic split function for a Scanner that returns each space-separated word of text or HTML tag, with surrounding spaces deleted. It will never return an empty string. The definition of space is set by unicode.IsSpace.

Types

type Heffalump

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

Heffalump represents our buffer pool and markov map from Heffalump

var DefaultHeffalump *Heffalump

DefaultHeffalump represents a Heffalump type

func NewHeffalump

func NewHeffalump(mm MarkovMap, buffsize int) *Heffalump

NewHeffalump instantiates a new Heffalump for markov generation and buffer/io operations

func (*Heffalump) WriteHell

func (h *Heffalump) WriteHell(bw *bufio.Writer) (int64, error)

WriteHell writes markov chain heffalump hell to the provided io.Writer

type MarkovMap

type MarkovMap map[tokenPair][]string

MarkovMap is a map that acts as a Markov chain generator.

var DefaultMarkovMap MarkovMap

func MakeMarkovMap

func MakeMarkovMap(r io.Reader) MarkovMap

MakeMarkovMap makes an empty MakeMarkov and fills it with r.

func (MarkovMap) Add

func (mm MarkovMap) Add(w1, w2, w3 string)

Add adds a three token sequence to the map.

func (MarkovMap) Fill

func (mm MarkovMap) Fill(r io.Reader)

Fill adds all the tokens in r to a MarkovMap

func (MarkovMap) Get

func (mm MarkovMap) Get(w1, w2 string) string

Get pseudo-randomly chooses a possible suffix to w1 and w2.

func (MarkovMap) Read

func (mm MarkovMap) Read(p []byte) (n int, err error)

Read fills p with data from calling Get on the MarkovMap.

Jump to

Keyboard shortcuts

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