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

package util

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


Package Files

file.go messages.go slice.go

func Contains Uses

func Contains(slice []string, text string) bool

Contains checks if a string slice contains a specified string

func Difference Uses

func Difference(slice []string, slice2 []string) (difference []string)

Difference returns the difference of slice and slice2

func GetMessage Uses

func GetMessage(locale, tag string) string

GetMessage retrieves a message tag and returns a random message chose from res/datasets/messages.json

func Index Uses

func Index(slice []string, text string) int

Index returns a string index in a string slice

func ReadFile Uses

func ReadFile(path string) (bytes []byte)

ReadFile returns the bytes of a file searched in the path and beyond it

type Message Uses

type Message struct {
    Tag      string   `json:"tag"`
    Messages []string `json:"messages"`

Message contains the message's tag and its contained matched sentences

func GetMessageByTag Uses

func GetMessageByTag(tag, locale string) Message

GetMessageByTag returns a message found by the given tag and locale

func GetMessages Uses

func GetMessages(locale string) []Message

GetMessages returns the cached messages for the given locale

func SerializeMessages Uses

func SerializeMessages(locale string) []Message

SerializeMessages serializes the content of `res/datasets/messages.json` in JSON

Package util imports 5 packages (graph) and is imported by 10 packages. Updated 2020-06-18. Refresh now. Tools for package owners.