Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultNormalizer ¶
DefaultNormalizer lowercases and strips punctuation.
Types ¶
type Document ¶
type Document struct {
Name string `json:"name"`
Date string `json:"date"`
Preview string `json:"preview"` // first N characters, using ellipsis if truncated
Length int // number of words in the document
Content string // full content, lowercase
}
func DefaultLoader ¶
DefaultLoader loads documents from the filesystem using the provided options.
type Index ¶
type Index struct {
TMap map[string]TermFreq `json:"t_map"` // term map
// contains filtered or unexported fields
}
Index: {docs, tMap:{term: TermFreq:{idf, tfMap:{doc1: tf1, doc2: tf2, ...}}}}
func NewIndex ¶
NewIndex creates a new search index from the documents loaded using the provided loader function.
func (Index) Search ¶
func (idx Index) Search(terms []string, opts SearchOpts) ([]SearchResult, error)
Search returns an ordering of the documents based on the search terms
func (Index) TotalWords ¶
Return the total number of words in all documents.
type Normalizer ¶
Normalizer converts a raw document string into a cleaned version before tokenization (e.g. lowercase, strip punctuation, etc.).
type SearchOpts ¶ added in v0.1.5
type SearchOpts struct {
Limit int
}
type SearchResult ¶
Click to show internal directories.
Click to hide internal directories.