Documentation ¶
Index ¶
- Constants
- Variables
- func CreateRoot() error
- func OrderBySimilarity(arr []NameSimilarity) ([]string, error)
- func TrustedIPs() ([]string, error)
- type Log
- type NameSimilarity
- type NameType
- func GetAllNames() ([]NameType, error)
- func GetNameById(id int) (*NameType, *gorm.DB, error)
- func GetNameByName(name string) (*NameType, error)
- func GetSimilarMatch(name string, allNames []NameType) (*NameType, error)
- func SearchCacheMetaphone(metaphone string, cache []NameType) []NameType
- func SearchCanonicalName(paradigmName string, threshold float32, allNames []NameType, ...) (*NameType, error)
- func SearchSimilarMetaphone(paradigmMetaphone string, allNames []NameType) []NameType
- type User
- type UserInputBody
Constants ¶
const SimilarityThreshold = 0.8
Variables ¶
var DB *gorm.DB
var IPs []string
Functions ¶
func OrderBySimilarity ¶
func OrderBySimilarity(arr []NameSimilarity) ([]string, error)
OrderBySimilarity sorts an array of NameSimilarity objects by descending similarity and then by ascending name length.
func TrustedIPs ¶
TrustedIPs returns all IPs from users on the database
Types ¶
type Log ¶
type Log struct { gorm.Model Time string Status string Latency string IP string Method string Path string }
Log is a struct representing a log record
type NameSimilarity ¶
NameSimilarity contains a name and a Levenshtein score
func SearchSimilarNames ¶
func SearchSimilarNames(paradigmName string, allNames []NameType, threshold float32) []NameSimilarity
SearchSimilarNames returns a slice of NameLevenshtein elements that have a similarity score higher than the given threshold to the given paradigmName
type NameType ¶
type NameType struct { gorm.Model Name string `gorm:"unique" json:"Name,omitempty"` Classification string `json:"Classification,omitempty"` Metaphone string `json:"Metaphone,omitempty"` NameVariations string `json:"NameVariations,omitempty"` }
NameType is a struct representing a name record
func GetAllNames ¶
GetAllNames returns all non-deleted names in the database
func GetNameById ¶
GetNameById returns the name record with the given ID (non-deleted)
func GetNameByName ¶
GetNameByName returns the name record with the given name (non-deleted)
func GetSimilarMatch ¶
GetSimilarMatch searches for a similar match for a given name in a slice of NameType.
func SearchCacheMetaphone ¶
SearchCacheMetaphone searches for all NameType objects in the cache that have a matching metaphone value and returns them as a slice
func SearchCanonicalName ¶
func SearchCanonicalName(paradigmName string, threshold float32, allNames []NameType, matchingMetaphoneNames []NameType, nameVariations []string) (*NameType, error)
SearchCanonicalName searches for a canonical name in a list of names using a given threshold for similarity matching.
func SearchSimilarMetaphone ¶
SearchSimilarMetaphone returns a slice of NameType elements that have a metaphone similar to the given paradigmMetaphone
func (*NameType) CreateName ¶
CreateName creates a new name record
func (*NameType) DeleteName ¶
DeleteName deletes a name from the database by its ID.
type User ¶
type User struct { gorm.Model `json:"Gorm.Model"` // Use backticks for struct tags Email string `gorm:"unique" json:"Email,omitempty"` Password string `json:"Password,omitempty"` IP string `json:"IP,omitempty"` }
User is the struct for API users
func GetUserByEmail ¶
GetUserByEmail gets a user by their email
func (*User) DeleteUser ¶
DeleteUser deletes a user by their ID
type UserInputBody ¶
type UserInputBody struct { Email string `json:"Email,omitempty"` Password string `json:"Password,omitempty"` }
UserInputBody is the struct for validation middlewares