fate

package module
v0.0.0-...-794a06e Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 15 Imported by: 3

README

fate

fate is a framework for generating text. It's a formal split from my work in the Python and Go versions of cobe.

cobe minimized program memory to run on a virtual machine with 64MB of RAM, and to that end used an on-disk database for its language model. That restriction seems quaint today.

This work begins with a highly performant trigram language model that can generate replies to text and has reasonable memory usage.

Usage is straightforward: docs are at godoc.org. I've kept the API surface very small to start.

You can try it out on the command line:

$ go get github.com/pteichman/fate/cmd/fate-console
$ fate-console <text files>

That will learn everything in the files (line by line) and set up an interactive reply loop.

Documentation

Overview

Package fate is a text generation library.

Index

Constants

This section is empty.

Variables

View Source
var DefaultStemmer = &cleaner{}

DefaultStemmer makes reply inputs insensitive to case, accents, and punctuation.

Functions

func QuoteFix

func QuoteFix(s string) string

QuoteFix automatically balances quotes/parens/etc in text strings.

Types

type Config

type Config struct {
	// Stemmer makes all tokens go through a normalization process
	// when created. Words that stem the same mean the same thing.
	Stemmer Stemmer
	Rand    rand.Source
}

Config holds Model configuration data. An empty Config struct indicates the default values for each.

type Model

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

Model is a trigram language model that can learn and respond to text.

func NewModel

func NewModel(opts Config) *Model

NewModel constructs an empty language model.

func (*Model) Learn

func (m *Model) Learn(text string)

Learn observes the text in a string and makes it available for later replies.

func (*Model) Reply

func (m *Model) Reply(text string) string

Reply generates a reply string to str, given the current state of the language model. If no text has been learned, returns an empty string.

type Stemmer

type Stemmer interface {
	Stem(string) string
}

Stemmer normalizes a string to its stem.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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