Documentation
¶
Index ¶
- Variables
- func FindMathOperation(entry string) string
- func FindMoviesGenres(locale, content string) (output []string)
- func FindName(sentence string) string
- func FindNumberOfDecimals(locale, entry string) int
- func FindRangeLimits(local, entry string) ([]int, error)
- func LevenshteinContains(sentence, matching string, rate int) bool
- func LevenshteinDistance(first, second string) int
- func SearchMusic(locale, sentence string) (music, artist string)
- func SearchReason(locale, sentence string) string
- func SearchTokens(sentence string) []string
- func SerializeNames() (names []string)
- type Country
- type Movie
- type ReasonKeyword
- type SpotifyKeywords
- type Subject
Constants ¶
This section is empty.
Variables ¶
var MathDecimals = map[string]string{
"en": `(\d+( |-)decimal(s)?)|(number (of )?decimal(s)? (is )?\d+)`,
}
MathDecimals is the map for having the regex on decimals in different languages
var ( // MoviesGenres initializes movies genres in different languages MoviesGenres = map[string][]string{ "en": { "Action", "Adventure", "Animation", "Children", "Comedy", "Crime", "Documentary", "Drama", "Fantasy", "Film-Noir", "Horror", "Musical", "Mystery", "Romance", "Sci-Fi", "Thriller", "War", "Western", }, } )
var ReasonKeywords = map[string]ReasonKeyword{
"en": {
That: "that",
To: "to",
},
}
ReasonKeywords is for having the keywords in different languages
var SpotifyKeyword = map[string]SpotifyKeywords{
"en": {
Play: "play",
From: "from",
On: "on",
},
}
SpotifyKeyword is the map for having the music keywords in different languages
Functions ¶
func FindMathOperation ¶
FindMathOperation finds a math operation in a string an returns it
func FindMoviesGenres ¶
FindMoviesGenres returns an array of genres found in the entry string
func FindName ¶
FindName returns a name found in the given sentence or an empty string if no name has been found
func FindNumberOfDecimals ¶
FindNumberOfDecimals finds the number of decimals asked in the query
func FindRangeLimits ¶
FindRangeLimits finds the range for random numbers and returns a sorted integer array
func LevenshteinContains ¶
LevenshteinContains checks for a given matching string in a given sentence with a minimum rate for Levenshtein.
func LevenshteinDistance ¶
LevenshteinDistance calculates the Levenshtein Distance between two given words and returns it. Please see https://en.wikipedia.org/wiki/Levenshtein_distance.
func SearchMusic ¶
SearchMusic returns a music title and artist found from the given sentence
func SearchReason ¶
SearchReason returns the reason found in the given sentence for the reminders, here is an example: "Remind me that I need to **call mom** tomorrow".
func SearchTokens ¶
SearchTokens searches 2 tokens in the given sentence and returns it.
func SerializeNames ¶
func SerializeNames() (names []string)
SerializeNames retrieves all the names from res/datasets/names.txt and returns an array of names
Types ¶
type Country ¶
type Country struct {
Name map[string]string `json:"name"`
Capital string `json:"capital"`
Code string `json:"code"`
Area float64 `json:"area"`
Currency string `json:"currency"`
}
Country is the serializer of the countries.json file in the res folder
func FindCountry ¶
FindCountry returns the country found in the sentence and if no country is found, returns an empty Country struct
func SerializeCountries ¶
func SerializeCountries() (countries []Country)
SerializeCountries returns a list of countries, serialized from `res/datasets/countries.json`
type Movie ¶
Movie is the serializer from res/datasets/movies.csv
func SearchMovie ¶
SearchMovie search a movie for a given genre
func SerializeMovies ¶
func SerializeMovies() (movies []Movie)
SerializeMovies retrieves the content of res/datasets/movies.csv and serialize it
type ReasonKeyword ¶
ReasonKeyword are used to find reason for different languages
type SpotifyKeywords ¶
SpotifyKeywords are the keywords used to get music name
type Subject ¶
type Subject struct {
Name map[string]string `json:"name"`
Info string `json:"info"`
Opinion string `json:"opinion"`
}
Subject is the serializer of the knowledge.json file in the res folder
func FindSubject ¶
FindSubject returns the subject found in the sentence and if no subject is found, returns an empty Subject struct
func SerializeKnowledge ¶
func SerializeKnowledge() (knowledge []Subject)
SerializeKnowledge returns a list of knowledge, serialized from `res/datasets/knowledge.json`