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

package analysis

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


Package Files

coverage.go format.go intents.go sentence.go


const DontUnderstand = "don't understand"

DontUnderstand contains the tag for the don't understand messages

func CacheIntents Uses

func CacheIntents(locale string, _intents []Intent)

CacheIntents set the given intents to the global variable intents

func GetCoverage Uses

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

GetCoverage encodes the coverage of each language in json

func LogResults Uses

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

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

func RandomizeResponse Uses

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

type Coverage Uses

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 Uses

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 Uses

type Document struct {
    Sentence Sentence
    Tag      string

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

func Organize Uses

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 Uses

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 Uses

func GetIntentByTag(tag, locale string) Intent

GetIntentByTag returns an intent found by given tag and locale

func GetIntents Uses

func GetIntents(locale string) []Intent

GetIntents returns the cached intents

func SerializeIntents Uses

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

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

func SerializeModulesIntents Uses

func SerializeModulesIntents(locale string) []Intent

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

type LocaleCoverage Uses

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 Uses

type Result struct {
    Tag   string
    Value float64

Result contains a predicted value with its tag and its value

type Sentence Uses

type Sentence struct {
    Locale  string
    Content string

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

func NewSentence Uses

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

NewSentence returns a Sentence object where the content has been arranged

func (Sentence) Calculate Uses

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 Uses

func (sentence Sentence) PredictTag(neuralNetwork network.Network) string

PredictTag classifies the sentence with the model

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 16 packages (graph) and is imported by 3 packages. Updated 2020-05-21. Refresh now. Tools for package owners.