language

package
v0.0.0-...-c4bfc47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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+)`,
	"el": `(\d+( |-)δεκαδικ(ό|ά)?)|(αριθμός (από )?δεκαδικ(ό|ά)? (είναι )?\d+)`,
}

MathDecimals is the map for having the regex on decimals in different languages

View Source
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",
		},
		"it": {
			"Azione", "Avventura", "Animazione", "Bambini", "Commedia", "Poliziesco", "Documentario", "Dramma", "Fantasia",
			"Film-Noir", "Orrore", "Musical", "Mistero", "Romantico", "Fantascienza", "Giallo", "Guerra", "Western",
		},
		"nl": {
			"Actie", "Avontuur", "Animatie", "Kinderen", "Komedie", "Krimi", "Documentaire", "Drama", "Fantasie",
			"Film-Noir", "Horror", "Musical", "Mysterie", "Romantiek", "Sci-Fi", "Thriller", "Oorlog", "Western",
		},
		"el": {
			"Δράση", "Περιπέτεια", "Κινούμενα Σχέδια", "Παιδικά", "Κωμωδία", "Έγκλημα", "Ντοκιμαντέρ", "Δράμα", "Φαντασία",
			"Film-Noir", "Τρόμου", "Μουσική", "Μυστηρίου", "Ρομαντική", "Επιστημονική Φαντασία", "Θρίλλερ", "Πολέμου", "Western",
		},
	}
)
View Source
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",
	},
	"el": {
		That: "το οποίο",
		To:   "στο",
	},
}

ReasonKeywords is for having the keywords in different languages

View Source
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",
	},
	"it": {
		Play: "suona",
		From: "da",
		On:   "a",
	},
	"tr": {
		Play: "Başlat",
		From: "dan",
		On:   "kadar",
	},
	"nl": {
		Play: "speel",
		From: "van",
		On:   "op",
	},
	"el": {
		Play: "αναπαραγωγή",
		From: "από",
		On:   "στο",
	},
}

SpotifyKeyword is the map for having the music keywords in different languages

Functions

func FindMathOperation

func FindMathOperation(entry string) string

FindMathOperation finds a math operation in a string an returns it

func FindMoviesGenres

func FindMoviesGenres(locale, content string) (output []string)

FindMoviesGenres returns an array of genres found in the entry string

func FindName

func FindName(sentence string) string

FindName returns a name found in the given sentence or an empty string if no name has been found

func FindNumberOfDecimals

func FindNumberOfDecimals(locale, entry string) int

FindNumberOfDecimals finds the number of decimals asked in the query

func FindRangeLimits

func FindRangeLimits(local, entry string) ([]int, error)

FindRangeLimits finds the range for random numbers and returns a sorted integer array

func LevenshteinContains

func LevenshteinContains(sentence, matching string, rate int) bool

LevenshteinContains checks for a given matching string in a given sentence with a minimum rate for Levenshtein.

func LevenshteinDistance

func LevenshteinDistance(first, second string) int

LevenshteinDistance calculates the Levenshtein Distance between two given words and returns it. Please see https://en.wikipedia.org/wiki/Levenshtein_distance.

func SearchMusic

func SearchMusic(locale, sentence string) (music, artist string)

SearchMusic returns a music title and artist found from the given sentence

func SearchReason

func SearchReason(locale, sentence string) string

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

func SearchTokens(sentence string) []string

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

func FindCountry(locale, sentence string) Country

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

type Movie struct {
	Name   string
	Genres []string
	Rating float64
}

Movie is the serializer from res/datasets/movies.csv

func SearchMovie

func SearchMovie(genre, userToken string) (output Movie)

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

type ReasonKeyword struct {
	That string
	To   string
}

ReasonKeyword are used to find reason for different languages

type SpotifyKeywords

type SpotifyKeywords struct {
	Play string
	From string
	On   string
}

SpotifyKeywords are the keywords used to get music name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL