analysis

package
v2.1.2-0...-e76204f Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 16 Imported by: 3

Documentation

Index

Constants

View Source
const DontUnderstand = "don't understand"

DontUnderstand contains the tag for the don't understand messages

Variables

This section is empty.

Functions

func CacheIntents

func CacheIntents(locale string, _intents []Intent)

CacheIntents set the given intents to the global variable intents

func GetCoverage

func GetCoverage(writer http.ResponseWriter, _ *http.Request)

GetCoverage encodes the coverage of each language in json

func LogResults

func LogResults(locale, entry string, results []Result)

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

func RandomizeResponse

func RandomizeResponse(locale, entry, tag, token string) (string, string)

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

Types

type Coverage

type Coverage struct {
	Modules  CoverageDetails `json:"modules"`
	Intents  CoverageDetails `json:"intents"`
	Messages CoverageDetails `json:"messages"`
}

Coverage is the coverage for a single language which contains the coverage details of each section

type CoverageDetails

type CoverageDetails struct {
	NotCovered []string `json:"not_covered"`
	Coverage   int      `json:"coverage"`
}

CoverageDetails are the details of items not covered and the coverage percentage

type Document

type Document struct {
	Sentence Sentence
	Tag      string
}

Document is any sentence from the intents' patterns linked with its tag

func Organize

func Organize(locale string) (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"`
}

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 GetIntentByTag

func GetIntentByTag(tag, locale string) Intent

GetIntentByTag returns an intent found by given tag and locale

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

func SerializeModulesIntents

func SerializeModulesIntents(locale string) []Intent

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

type LocaleCoverage

type LocaleCoverage struct {
	Tag      string   `json:"locale_tag"`
	Language string   `json:"language"`
	Coverage Coverage `json:"coverage"`
}

LocaleCoverage is the element for the coverage of each language

type Result

type Result struct {
	Tag   string
	Value float64
}

Result contains a predicted value with its tag and its value

type Sentence

type Sentence struct {
	Locale  string
	Content string
}

A Sentence represents simply a sentence with its content as a string

func NewSentence

func NewSentence(locale, content string) (sentence Sentence)

NewSentence returns a Sentence object where the content has been arranged

func (Sentence) Calculate

func (sentence Sentence) Calculate(cache gocache.Cache, neuralNetwork network.Network, token 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(neuralNetwork network.Network) string

PredictTag classifies the sentence with the model

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