chain

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

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Starter = "SOS" // StartOfSentence
	Ender   = "EOS" // EndOfSentence
)
View Source
const MaxLoops = 50

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain struct {
	Links map[string]*Probability // map[word]possible words
	// contains filtered or unexported fields
}

func NewChain

func NewChain(file string) (*Chain, error)

func (*Chain) Add

func (c *Chain) Add(msg string) error
func (c *Chain) AddLink(start, end string, count int) error

func (*Chain) Close

func (c *Chain) Close()

func (*Chain) Load

func (c *Chain) Load(filename string) error

func (*Chain) Optimize

func (c *Chain) Optimize() error

Optimize uses the count value to reduce the number of entries

func (*Chain) Predict

func (c *Chain) Predict(prompt string) (string, bool)

func (*Chain) Reset

func (c *Chain) Reset() error

func (*Chain) Write

func (c *Chain) Write(entry LinkEntry) error

type LinkEntry

type LinkEntry struct {
	Start string `json:"start"`
	Next  string `json:"next"`
	Count int    `json:"count"`
}

type Probability

type Probability struct {
	Data map[string]int
	Sum  int
	// contains filtered or unexported fields
}

func NewProbability

func NewProbability() *Probability

func (*Probability) AddWord

func (p *Probability) AddWord(word string, count int)

func (*Probability) Predict

func (p *Probability) Predict() string

Jump to

Keyboard shortcuts

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