olivia: github.com/olivia-ai/olivia/analysis Index | Files

package analysis

import "github.com/olivia-ai/olivia/analysis"


Package Files

intents.go sentence.go


const DontUnderstand = "don't understand"

func Arrange Uses

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 Uses

func LogResults(entry string, results []Result)

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

func RandomizeResponse Uses

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

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

type Document Uses

type Document struct {
    Sentence Sentence
    Tag      string

func Organize Uses

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 Uses

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

func SerializeIntents Uses

func SerializeIntents() []Intent

func SerializeModulesIntents Uses

func SerializeModulesIntents() []Intent

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

type Result Uses

type Result struct {
    Tag   string
    Value float64

type Sentence Uses

type Sentence struct {
    Content string

func NewSentence Uses

func NewSentence(content string) Sentence

NewSentence returns a Sentence object where the content has been arranged

func (Sentence) Calculate Uses

func (sentence Sentence) Calculate(cache gocache.Cache, network neuralnet.NeuralNetwork, token string) (string, string)

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

func (Sentence) PredictTag Uses

func (sentence Sentence) PredictTag(network neuralnet.NeuralNetwork) string

Classify the sentence with the model

func (Sentence) Tokenize Uses

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

Tokenize returns the sentence split in stemmed words

func (Sentence) WordsBag Uses

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

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

Package analysis imports 14 packages (graph) and is imported by 2 packages. Updated 2019-08-09. Refresh now. Tools for package owners.