types

package
v0.0.0-...-62718c5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheIntents

func CacheIntents(locale string, _intents []Intent)

CacheIntents set the given intents to the global variable intents

Types

type Document

type Document struct {
	Text          string     `json:"text"`
	Summary       string     `json:"Summary"`
	Meaning       string     `json:"meaning"`
	Sentences     []Sentence `json:"sentences"`
	Tokens        []string   `json:"tokens"`
	WordFrequence FreqDist
	Tokenizer     string
}

func NewDocument

func NewDocument(text string) Document

func (*Document) Learn

func (d *Document) Learn() *Document

func (*Document) PrepareSentences

func (d *Document) PrepareSentences()

type FreqDist

type FreqDist struct {
	Samples map[string]int
}

A frequency distribution for the outcomes of an experiment. A frequency distribution records the number of times each outcome of an experiment has occurred. For example, a frequency distribution could be used to record the frequency of each word type in a document. Formally, a frequency distribution can be defined as a function mapping from each sample to the number of times that sample occurred as an outcome. Frequency distributions are generally constructed by running a number of experiments, and incrementing the count for a sample every time it is an outcome of an experiment.

func NewFreqDist

func NewFreqDist(samples map[string]int) *FreqDist

func (*FreqDist) B

func (f *FreqDist) B() int

B returns the total number of sample values (or "bins") that have counts greater than zero.

func (*FreqDist) CumulativeFrequencies

func (f *FreqDist) CumulativeFrequencies(Samples []string) []int

Return the cumulative frequencies of the specified Samples. If no Samples are specified, all counts are returned, starting with the largest.

func (*FreqDist) Freq

func (f *FreqDist) Freq(sample string) float64

Return the frequency of a given sample. The frequency of a sample is defined as the count of that sample divided by the total number of sample outcomes that have been recorded by this FreqDist. The count of a sample is defined as the number of times that sample outcome was recorded by this FreqDist. Frequencies are always real numbers in the range [0, 1].

func (*FreqDist) Hapaxes

func (f *FreqDist) Hapaxes() []string

Return a list of all Samples that occur once (hapax legomena)

func (*FreqDist) Max

func (f *FreqDist) Max() (string, error)

Return the sample with the greatest number of outcomes in this frequency distribution. If two or more Samples have the same number of outcomes, return one of them; which sample is returned is undefined.

func (*FreqDist) N

func (f *FreqDist) N() float64

N returns the total number of sample outcomes that have been recorded by this FreqDist.

func (*FreqDist) RtoNr

func (f *FreqDist) RtoNr(bins int) map[int]int

Return the dictionary mapping r to Nr, the number of Samples with frequency r, where Nr > 0

type Intent

type Intent struct {
	Tag       string   `json:"tag"`
	Patterns  []string `json:"patterns"`
	Responses []string `json:"responses"`
	Context   string   `json:"context"`
}

Intent is a way to group sentences that mean the same thing and link them with a tag which represents what they mean, some responses that the bot can reply and a context

func GetIntents

func GetIntents(locale string) []Intent

GetIntents returns the cached intents

func SerializeIntents

func SerializeIntents(locale string) (_intents []Intent)

SerializeIntents returns a list of intents retrieved from the given intents file

type Sentence

type Sentence struct {
	Text      string   `json:"text"`
	Summary   string   `json:"Summary"`
	Meaning   string   `json:"meaning"`
	Words     []Word   `json:"words"`
	Tokens    []string `json:"tokens"`
	Tokenizer string   `json:"tokenizer"`
}

func NewSentence

func NewSentence(text string) Sentence

func (*Sentence) ApplyTokenizer

func (s *Sentence) ApplyTokenizer(tokenizer tokenizers.Tokenizer)

func (*Sentence) Learn

func (s *Sentence) Learn() *Sentence

func (*Sentence) PrepareMeaning

func (s *Sentence) PrepareMeaning() *Sentence

func (*Sentence) PrepareSummary

func (s *Sentence) PrepareSummary() *Sentence

func (*Sentence) PrepareWords

func (s *Sentence) PrepareWords()

type Word

type Word struct {
	Text     string   `json:"text"`
	PosTag   string   `json:"pos"`
	Stem     string   `json:"stem"`
	Vector   float64  `json:"vector"`
	Meaning  string   `json:"meaning"`
	Letters  []string `json:"letters"`
	Synonyms []string `json:"synonyms"`
}

func NewWord

func NewWord(text string) Word

func (*Word) ApplyStemmer

func (w *Word) ApplyStemmer() *Word

Applies a stemmer to turn words like Cats to Cat

func (*Word) AttachPOStag

func (w *Word) AttachPOStag()

func (*Word) Learn

func (w *Word) Learn() *Word

Preloads all other needed fields

func (*Word) PrepareMeaning

func (w *Word) PrepareMeaning() *Word

func (*Word) PrepareSynonyms

func (w *Word) PrepareSynonyms() *Word

Applies words with similer meaning

Jump to

Keyboard shortcuts

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