opeth

package
v0.0.0-...-7e69f2d Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2017 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToMap

func AddToMap(prefix, toAdd string, aMap CountedStringMap)

Add to map checks if the key/value pair exists in the map. If not, we create them, and if so, we either increment the counter on the value or initialize it if it didn't exist previously.

Types

type CountedString

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

Since both maps (the prefix -> suffix and canonical -> representation) operate about the same way, we abstract their representation into a notion of CountedStrings, where the values of the map contain both the string we care about and a count of how often it occurs.

type CountedStringList

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

A CountedStringList is a list of all the CountedStrings for a given prefix, and a total number of times that prefix occurs (necessary, with the CountedString hits, for probability calculation).

func (CountedStringList) DrawProbabilistically

func (cs CountedStringList) DrawProbabilistically() string

func (*CountedStringList) GetSuffix

func (s *CountedStringList) GetSuffix(lookFor string) (*CountedString, bool)

For testing.

type CountedStringMap

type CountedStringMap map[string]*CountedStringList

Map from a prefix in canonical form to CountedStringLists, where one will move canonical prefixes to suffixes, and another to words -> representation.

type Generator

type Generator struct {
	PrefixLen  int
	CharLimit  int
	Data       CountedStringMap // suffix map
	Reps       CountedStringMap // representation map
	Beginnings []string         // acceptable ways to start a tweet.
}

Generators gives us all we need to build a fresh data model to generate from.

func CreateGenerator

func CreateGenerator(prefixLen int, charLimit int) *Generator

CreateGenerator returns a Generator that is fully initialized and ready for use.

func (*Generator) AddSeeds

func (g *Generator) AddSeeds(input string)

AddSeeds takes in a string, breaks it into prefixes, and adds it to the data model.

func (*Generator) GenerateFromPrefix

func (g *Generator) GenerateFromPrefix(prefix string) string

We expose this version primarily for testing.

func (*Generator) GenerateText

func (g *Generator) GenerateText() string

Generates text from the given generator. It stops when the character limit has run out, or it encounters a prefix it has no suffixes for.

type Opeth

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

func NewOpethPlugin

func NewOpethPlugin() *Opeth

func (*Opeth) OnMessage

func (o *Opeth) OnMessage(m *dgofw.DiscordMessage)

Jump to

Keyboard shortcuts

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