analysis

package
v0.0.0-...-1c541a2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DontUnderstand = "don't understand"

Variables

This section is empty.

Functions

func Arrange

func Arrange(text string) string

Arrange check the format of a string to normalize it, put the string to lower case, remove ignored characters

func LogResults

func LogResults(entry string, results []Result)

LogResults print in the console the sentence and its tags sorted by prediction

func RandomizeResponse

func RandomizeResponse(entry string, tag string, userId string) string

RandomizeResponse takes the entry message, the response tag and the userID and returns a random message from res/intents.json where the triggers are applied

Types

type Document

type Document struct {
	Sentence Sentence
	Tag      string
}

func Organize

func Organize() (words, classes []string, documents []Document)

Organize intents with an array of all words, an array with a representative word of each tag and an array of Documents which contains a word list associated with a tag

type Intent

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

func SerializeIntents

func SerializeIntents() []Intent

func SerializeModulesIntents

func SerializeModulesIntents() []Intent

SerializeModulesIntents retrieves all the registered modules and returns an array of Intents

type Result

type Result struct {
	Tag   string
	Value float64
}

type Sentence

type Sentence struct {
	Content string
}

func NewSentence

func NewSentence(content string) Sentence

NewSentence returns a Sentence object where the content has been arranged

func (Sentence) Calculate

func (sentence Sentence) Calculate(cache gocache.Cache, network gonn.NeuralNetwork, userId string) (string, string)

Calculate send the sentence content to the neural network and returns a response with the matching tag

func (Sentence) PredictTag

func (sentence Sentence) PredictTag(n gonn.NeuralNetwork) string

Classify the sentence with the model

func (Sentence) Tokenize

func (sentence Sentence) Tokenize() (tokenizedWords []string)

Tokenize returns the sentence split in stemmed words

func (Sentence) WordsBag

func (sentence Sentence) WordsBag(words []string) (bag []float64)

WordsBag retrieves the intents words and returns the sentence converted in a bag of words

Jump to

Keyboard shortcuts

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