Documentation ¶
Index ¶
- type Document
- type Index
- func (i *Index) AddItem(item IndexItem) error
- func (i *Index) AddString(input string) error
- func (i *Index) FindBestMatch(input string) string
- func (i *Index) FindMatchingStrings(input string) []string
- func (i *Index) FindSimilarStrings(input string) []string
- func (i *Index) GetItem(id string) IndexItem
- func (i *Index) GetItemWithMetadata(id string) *IndexItemWithMetadata
- func (i *Index) GetMinScore() float64
- func (i *Index) GetWarp() float64
- func (i *Index) IterateSimilar(input string, min float64, limit int) <-chan MatchResult
- func (i *Index) SetMinScore(min float64)
- func (i *Index) SetWarp(w float64)
- type IndexItem
- type IndexItemDepot
- type IndexItemWithMetadata
- type InvertedIndex
- type MatchResult
- type Token
- type Tokenize
- type Tokenizer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
func NewDocument ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Example ¶
trigram := NewIndex(3) inputs := []string{ `...`, `...`, `...`, } for _, v := range inputs { trigram.AddString(v) } // Find strings whose scores are above trigram.GetMinScore() // (which is by default 0) matches := trigram.FindSimilarStrings(`...`) log.Printf("%#v", matches) // Find 1 best match (the best score) out of similar strings best := trigram.FindBestMatch(`...`) log.Printf("%s", best) // Iterate match results minScore := 0.5 limit := 0 c := trigram.IterateSimilar(` ... your input ...`, minScore, limit) for r := range c { log.Printf("Item id %s matched with score %d", r.Item.Id(), r.Score) log.Printf("Content of Item was %s", r.Item.Content()) }
Output:
func (*Index) FindBestMatch ¶
func (*Index) FindMatchingStrings ¶
func (*Index) FindSimilarStrings ¶
func (*Index) GetItemWithMetadata ¶
func (i *Index) GetItemWithMetadata(id string) *IndexItemWithMetadata
func (*Index) GetMinScore ¶
func (*Index) IterateSimilar ¶
func (i *Index) IterateSimilar(input string, min float64, limit int) <-chan MatchResult
search for similar strings in index, sending the search results to the returned channel. you can specify the minimum score and the maximum items to be fetched
func (*Index) SetMinScore ¶
type IndexItemDepot ¶
type IndexItemDepot map[string]*IndexItemWithMetadata
Map of item id to IndexItemWithMetadata. This object holds the IndexItem itself, as well as the number of ngrams in this document
type IndexItemWithMetadata ¶
type IndexItemWithMetadata struct {
// contains filtered or unexported fields
}
type InvertedIndex ¶
type MatchResult ¶
type Tokenize ¶
type Tokenize struct {
// contains filtered or unexported fields
}
Example ¶
input := `the quick red quick red fox red fox jumps fox jumps over jumps over the over the lazy the lazy brown lazy brown dog` n := NewTokenize(3, input) // Trigram for _, s := range n.Tokens() { log.Printf("segment = %s", s) }
Output:
func NewTokenize ¶
Click to show internal directories.
Click to hide internal directories.