Documentation ¶
Index ¶
- Constants
- func CacheIntents(locale string, _intents []Intent)
- func GetCoverage(writer http.ResponseWriter, _ *http.Request)
- func LogResults(locale, entry string, results []Result)
- func RandomizeResponse(locale, entry, tag, token string) (string, string)
- type Coverage
- type CoverageDetails
- type Document
- type Intent
- type LocaleCoverage
- type Result
- type Sentence
Constants ¶
const DontUnderstand = "don't understand"
DontUnderstand contains the tag for the don't understand messages
Variables ¶
This section is empty.
Functions ¶
func CacheIntents ¶
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 ¶
LogResults print in the console the sentence and its tags sorted by prediction
func RandomizeResponse ¶
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 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 ¶
GetIntentByTag returns an intent found by given tag and locale
func SerializeIntents ¶
SerializeIntents returns a list of intents retrieved from the given intents file
func SerializeModulesIntents ¶
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 Sentence ¶
A Sentence represents simply a sentence with its content as a string
func NewSentence ¶
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 ¶
PredictTag classifies the sentence with the model