olivia: github.com/olivia-ai/olivia/language Index | Files | Directories

package language

import "github.com/olivia-ai/olivia/language"

Index

Package Files

countries.go levenshtein.go math.go movies.go music.go names.go random.go reason.go token.go

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

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

func FindMathOperation Uses

func FindMathOperation(entry string) string

FindMathOperation finds a math operation in a string an returns it

func FindMoviesGenres Uses

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

FindMoviesGenres returns an array of genres found in the entry string

func FindName Uses

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 Uses

func FindNumberOfDecimals(locale, entry string) int

FindNumberOfDecimals finds the number of decimals asked in the query

func FindRangeLimits Uses

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

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

func LevenshteinContains Uses

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 Uses

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 Uses

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

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

func SearchReason Uses

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 Uses

func SearchTokens(sentence string) []string

SearchTokens searches 2 tokens in the given sentence and returns it.

func SerializeNames Uses

func SerializeNames() (names []string)

SerializeNames retrieves all the names from res/datasets/names.txt and returns an array of names

type Country Uses

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 Uses

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 Uses

func SerializeCountries() (countries []Country)

SerializeCountries returns a list of countries, serialized from `res/datasets/countries.json`

type Movie Uses

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

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

func SearchMovie Uses

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

SearchMovie search a movie for a given genre

func SerializeMovies Uses

func SerializeMovies() (movies []Movie)

SerializeMovies retrieves the content of res/datasets/movies.csv and serialize it

type ReasonKeyword Uses

type ReasonKeyword struct {
    That string
    To   string
}

ReasonKeyword are used to find reason for different languages

type SpotifyKeywords Uses

type SpotifyKeywords struct {
    Play string
    From string
    On   string
}

SpotifyKeywords are the keywords used to get music name

Directories

PathSynopsis
date

Package language imports 15 packages (graph) and is imported by 1 packages. Updated 2020-07-07. Refresh now. Tools for package owners.