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 Contains(wordList []string, s string) bool
- func Desserts() []string
- 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) (int64, error)
- func ExtractCurrency(s string) (int64, error)
- func ExtractYesNo(s string) (bool, error)
- 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 Restaurants() []string
- func SliceToString(ss []string, andor string) string
- func SuggestedPlace(s string) string
- func SuggestedProduct(s string, num uint) string
- func Transportation() []string
- func Welcome() string
- func Yes(s string) bool
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("couldn't extract requested type from string")
ErrNotFound is thrown when the requested type cannot be found in the string
var Prepositions = map[string]struct{}{
"aboard": struct{}{},
"about": struct{}{},
"above": struct{}{},
"across": struct{}{},
"after": struct{}{},
"against": struct{}{},
"along": struct{}{},
"amid": struct{}{},
"among": struct{}{},
"anti": struct{}{},
"around": struct{}{},
"as": struct{}{},
"at": struct{}{},
"before": struct{}{},
"behind": struct{}{},
"below": struct{}{},
"beneath": struct{}{},
"beside": struct{}{},
"besides": struct{}{},
"between": struct{}{},
"beyond": struct{}{},
"but": struct{}{},
"by": struct{}{},
"concerning": struct{}{},
"considering": struct{}{},
"despite": struct{}{},
"down": struct{}{},
"during": struct{}{},
"except": struct{}{},
"excepting": struct{}{},
"excluding": struct{}{},
"following": struct{}{},
"for": struct{}{},
"from": struct{}{},
"in": struct{}{},
"inside": struct{}{},
"into": struct{}{},
"like": struct{}{},
"minus": struct{}{},
"near": struct{}{},
"of": struct{}{},
"off": struct{}{},
"on": struct{}{},
"onto": struct{}{},
"opposite": struct{}{},
"outside": struct{}{},
"over": struct{}{},
"past": struct{}{},
"per": struct{}{},
"plus": struct{}{},
"regarding": struct{}{},
"round": struct{}{},
"save": struct{}{},
"since": struct{}{},
"than": struct{}{},
"through": struct{}{},
"to": struct{}{},
"toward": struct{}{},
"towards": struct{}{},
"under": struct{}{},
"underneath": struct{}{},
"unlike": struct{}{},
"until": struct{}{},
"up": struct{}{},
"upon": struct{}{},
"versus": struct{}{},
"via": struct{}{},
"with": struct{}{},
"within": struct{}{},
"without": struct{}{},
}
Prepositions contains the most commonly used prepositions.
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 Desserts ¶ added in v0.2.0
func Desserts() []string
Desserts returns a []string of dessert types useful in a plugin's object triggers
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
func ExtractCurrency ¶
ExtractCurrency returns an int64 if a currency is found, and throws an error if one isn't.
func ExtractYesNo ¶
ExtractYesNo determines whether a string contains a Yes or No response. This is useful for plugins to determine a user's answer to a Yes/No question.
func Foods ¶
func Foods() []string
Foods returns a list of foods useful in a plugin's object triggers.
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 Restaurants ¶ added in v0.2.0
func Restaurants() []string
Restaurants returns a []string of restaurant types useful in a plugin's object triggers
func SliceToString ¶
SliceToString converts a slice of strings into a natural-language list with appropriately placed commas and a custom and/or separator.
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 Transportation ¶ added in v0.2.0
func Transportation() []string
Transportation returns a list of vehicle types useful in a plugin's object triggers.
Types ¶
This section is empty.