Documentation ¶
Overview ¶
Package models contains the code for the models used in the cmd CLI package. It also contains utility functions used by these models, search functionality, and the drug configuration file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Drug ¶
type Drug struct { Name string `json:"name" yaml:"Name"` SearchTerms []string `json:"search_terms" yaml:"Search Terms"` Tags []string `json:"tags" yaml:"Tags"` }
Drug is the main data struct for parsing out each entry in the drugInfo yaml file.
func (*Drug) SearchText ¶
func (d *Drug) SearchText(text string) TextSearchResult
SearchText takes a Drug and searches the specified text for any close matches. This uses the Jaro-Winkler distance (>= 0.90) to define a "close" match and distance == 1.0 for an "exact" match. SearchText returns a TextSearchResult instance.
func (*Drug) SearchTextStrict ¶
func (d *Drug) SearchTextStrict(text string) TextSearchResult
SearchTextStrict does everything that SearchText does, but only looks for exact matches. Exact matches defined by Jaro-Winkler distance == 1.0. Returns a TextSearchResult instance.
type Drugs ¶
type Drugs struct {
Drugs []Drug `json:"drugs" yaml:"Drugs"`
}
Drugs puts an array of the Drug items into one struct for easy serialization.
type MatchResult ¶
MatchResult contains information regarding whether an Exact or Close match was found.
type MultipleResults ¶
type MultipleResults struct {
Data []Result `json:"data"`
}
MultipleResults holds many Result items in an array for easy serialization.
func (*MultipleResults) LoadFromFile ¶ added in v0.2.0
func (r *MultipleResults) LoadFromFile(path string)
LoadFromFile reads MultipleResults from the specified filepath.
func (MultipleResults) ToFile ¶
func (r MultipleResults) ToFile(path string)
ToFile writes MultipleResults to the specified filepath.
type Result ¶
type Result struct { RecordID string `json:"record_id"` DrugName string `json:"drug_name"` SimilarityRatio float64 `json:"similarity_ratio"` WordFound string `json:"word_found"` Tags []string `json:"tags"` TempID int `json:"-"` // ignores }
Result is the struct to manage the output of the program. This constitutes the RecordID, DrugName, SimilarityRatio, WordFound and Tags labels which are all assembled when running search.
type SearchResult ¶
SearchResult contains information regarding the JaroWinkler Distance between the Source and the Target.
type TextSearchResult ¶
type TextSearchResult struct {
// contains filtered or unexported fields
}
TextSearchResult contains the specific results of search functionality and is used to create a full Result item.