Documentation ¶
Overview ¶
Package language makes it easier to build plugins and natural-sounding responses. This package does the following four things:
- Provides easy-to-use helpers for returning commonly used, randomized text such as greetings.
- Normalizes varied user responses like "yup" or "nah" into something to be more easily used by plugins.
- Consolidates triggers by categories (e.g. automotive brands) if commonly used across plugins.
- Summarizes text using the custom rule-based algorithm found in summarize.go.
Index ¶
- Variables
- func Alcohol() []string
- func AutomotiveBrands() []string
- func Broken() []string
- func Confused() string
- func Contains(wordList []string, s string) bool
- func ExtractAddress(db *sqlx.DB, u *dt.User, s string) (*dt.Address, bool, error)
- func ExtractCities(db *sqlx.DB, in *dt.Msg) ([]dt.City, error)
- func ExtractCount(s string) sql.NullInt64
- func ExtractCurrency(s string) sql.NullInt64
- func ExtractYesNo(s string) sql.NullBool
- func Foods() []string
- func Greeting(r *rand.Rand, name string) string
- func Join(ss ...[]string) []string
- func NiceMeetingYou() string
- func No(s string) bool
- func Positive() string
- func Purchase() []string
- func QuestionLocation(loc string) string
- func Recommend() []string
- func RemoveStopWords(ss []string) []string
- func Repair() []string
- func SliceToString(ss []string, andor string) string
- func SuggestedPlace(s string) string
- func SuggestedProduct(s string, num uint) string
- func Vehicles() []string
- func Welcome() string
- func Yes(s string) bool
Constants ¶
This section is empty.
Variables ¶
var StopWords = []string{
"a",
"an",
"the",
}
StopWords are articles that can be ignored by Abot.
Functions ¶
func Alcohol ¶
func Alcohol() []string
Alcohol is a collection of alcohol related words useful in a plugin's object trigger.
func AutomotiveBrands ¶
func AutomotiveBrands() []string
AutomotiveBrands returns a list of automobile manufacturers useful in a plugin's object triggers.
func Broken ¶
func Broken() []string
Broken returns a slice of words related to something breaking, which is useful in a plugin's command trigger.
func Confused ¶
func Confused() string
Confused returns a randomized response signalling that Abot is confused or could not understand the user's request.
func ExtractAddress ¶
ExtractAddress will return an address from a user's message, whether it's a labeled address (e.g. "home", "office"), or a full U.S. address (e.g. 100 Penn St., CA 90000)
func ExtractCities ¶
ExtractCities efficiently from a user's message.
func ExtractCount ¶
ExtractCount returns a number from a user's message, useful in situations like:
Ava> How many would you like to buy? User> Order 5.
TODO this should return an *int64 to maintain consistency with the Extract API.
func ExtractCurrency ¶
ExtractCurrency returns a pointer to a string to allow a user a simple check to see if currency text was found. If the response is nil, no currency was found. This API design also maintains consistency when we want to extract and return a struct (which should be returned as a pointer).
func ExtractYesNo ¶
ExtractYesNo determines whether a string (typically a sentence sent by a user to Abot) contains a Yes or No response. This is useful for plugins to determine a user's answer to a Yes/No question.
TODO should be converted to return a *bool for consistency with the rest of the Extract API.
func Foods ¶
func Foods() []string
Foods returns a list of foods useful in a plugin's object triggers.
TODO expand.
func Join ¶
Join concatenates triggers together, like Recommend() and Broken(), ensuring no duplicates exist
func NiceMeetingYou ¶
func NiceMeetingYou() string
NiceMeetingYou is used to greet the user and request signup during an onboarding process.
func Positive ¶
func Positive() string
Positive returns a randomized positive response to a user message.
func Purchase ¶
func Purchase() []string
Purchase returns a slice of words related to purchasing something, which is useful in a plugin's command trigger.
func QuestionLocation ¶
QuestionLocation returns a randomized question asking a user where they are.
func Recommend ¶
func Recommend() []string
Recommend returns a slice of words related to recommending a product, which is useful in a plugin's command trigger.
func RemoveStopWords ¶
RemoveStopWords finds and removes stopwords from a slice of strings.
func Repair ¶
func Repair() []string
Repair returns a slice of words related to repairing something, which is useful in a plugin's command trigger.
func SliceToString ¶
SliceToString converts a slice of strings into a natural-language list with appropriately placed commas and a custom and/or seperator.
func SuggestedPlace ¶
SuggestedPlace returns a randomized place suggestion useful for recommending restaurants, businesses, etc.
func SuggestedProduct ¶
SuggestedProduct returns natural language, randomized text for a product suggestion.
func Vehicles ¶
func Vehicles() []string
Vehicles returns a list of vehicle types useful in a plugin's object triggers.
Types ¶
This section is empty.