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
Constants ¶
This section is empty.
Variables ¶
var MathDecimals = map[string]string{
"en": `(\d+( |-)decimal(s)?)|(number (of )?decimal(s)? (is )?\d+)`,
"de": `(\d+( |-)decimal(s)?)|(nummer (von )?decimal(s)? (ist )?\d+)`,
"fr": `(\d+( |-)decimale(s)?)|(nombre (de )?decimale(s)? (est )?\d+)`,
"es": `(\d+( |-)decimale(s)?)|(numero (de )?decimale(s)? (de )?\d+)`,
"ca": `(\d+( |-)decimal(s)?)|(nombre (de )?decimal(s)? (de )?\d+)`,
"it": `(\d+( |-)decimale(s)?)|(numero (di )?decimale(s)? (è )?\d+)`,
"tr": `(\d+( |-)desimal(s)?)|(numara (dan )?desimal(s)? (mı )?\d+)`,
"nl": `(\d+( |-)decimal(en)?)|(nummer (van )?decimal(en)? (is )?\d+)`,
"ru": `(\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", }, "de": { "Action", "Abenteuer", "Animation", "Kinder", "Komödie", "Verbrechen", "Dokumentarfilm", "Drama", "Fantasie", "Film-Noir", "Horror", "Musical", "Mystery", "Romance", "Sci-Fi", "Thriller", "Krieg", "Western", }, "fr": { "Action", "Aventure", "Animation", "Enfant", "Comédie", "Crime", "Documentaire", "Drama", "Fantaisie", "Film-Noir", "Horreur", "Musical", "Mystère", "Romance", "Science-fiction", "Thriller", "Guerre", "Western", }, "es": { "Acción", "Aventura", "Animación", "Infantil", "Comedia", "Crimen", "Documental", "Drama", "Fantasía", "Cine Negro", "Terror", "Musical", "Misterio", "Romance", "Ciencia Ficción", "Thriller", "Guerra", "Western", }, "ca": { "Acció", "Aventura", "Animació", "Nen", "Comèdia", "Crim", "Documental", "Drama", "Fantasia", "Film-Noir", "Horror", "Musical", "Misteri", "Romanç", "Ciència-ficció", "Thriller", "War", "Western", }, "nl": { "Actie", "Avontuur", "Animatie", "Kinderen", "Komedie", "Krimi", "Documentaire", "Drama", "Fantasie", "Film-Noir", "Horror", "Musical", "Mysterie", "Romantiek", "Sci-Fi", "Thriller", "Oorlog", "Western", }, "ru": { "Экшен", "Приключения", "Анимация", "Для детей", "Комедия", "Детектив", "Документальный", "Драма", "Фэнтази", "Нуар", "Ужасы", "Мюзикл", "Мистика", "Романтика", "Sci-Fi", "Триллер", "Военное кино", "Вестерн", }, } )
var ReasonKeywords = map[string]ReasonKeyword{
"en": {
That: "that",
To: "to",
},
"de": {
That: "das",
To: "zu",
},
"fr": {
That: "que",
To: "de",
},
"es": {
That: "que",
To: "para",
},
"ca": {
That: "que",
To: "a",
},
"it": {
That: "quel",
To: "per",
},
"tr": {
That: "için",
To: "sebebiyle",
},
"nl": {
That: "dat",
To: "naar",
},
"ru": {
That: "Что",
To: "через",
},
}
ReasonKeywords is for having the keywords in different languages
var SpotifyKeyword = map[string]SpotifyKeywords{
"en": {
Play: "play",
From: "from",
On: "on",
},
"de": {
Play: "spiele",
From: "von",
On: "auf",
},
"fr": {
Play: "joue",
From: "de",
On: "sur",
},
"es": {
Play: "Juega",
From: "de",
On: "en",
},
"ca": {
Play: "Juga",
From: "de",
On: "a",
},
"tr": {
Play: "Başlat",
From: "dan",
On: "kadar",
},
"nl": {
Play: "speel",
From: "van",
On: "op",
},
"ru": {
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