Documentation ¶
Overview ¶
Functions for finding documents by full text search
Functions for parsing a search query
Index ¶
- Variables
- type Collection
- type DatabaseDocFinder
- func (df DatabaseDocFinder) FindDocuments(ctx context.Context, dictSearcher *dictionary.Searcher, parser QueryParser, ...) (*QueryResults, error)
- func (df DatabaseDocFinder) FindDocumentsInCol(ctx context.Context, dictSearcher *dictionary.Searcher, parser QueryParser, ...) (*QueryResults, error)
- func (df DatabaseDocFinder) GetColMap() map[string]string
- func (df DatabaseDocFinder) GetDocFileMap() map[string]string
- func (df DatabaseDocFinder) GetDocMap() map[string]Document
- func (df DatabaseDocFinder) Inititialized() bool
- type DictQueryParser
- type DocFinder
- type Document
- type QueryParser
- type QueryResults
- type TextSegment
Constants ¶
This section is empty.
Variables ¶
var WEIGHT = []float64{0.080, 2.327, 3.040} // [BM25 words, BM25 bigrams, bit vector]
From logistic regression
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
GlossFile, Title string
}
type DatabaseDocFinder ¶ added in v0.0.17
type DatabaseDocFinder struct {
// contains filtered or unexported fields
}
DatabaseDocFinder holds stateful items needed for text search in database.
func (DatabaseDocFinder) FindDocuments ¶ added in v0.0.17
func (df DatabaseDocFinder) FindDocuments(ctx context.Context, dictSearcher *dictionary.Searcher, parser QueryParser, query string, advanced bool) (*QueryResults, error)
FindDocuments returns a QueryResults object containing matching collections, documents, and dictionary words. For dictionary lookup, a text segment will contains the QueryText searched for and possibly a matching dictionary entry. There will only be matching dictionary entries for Chinese words in the dictionary. If there are no Chinese words in the query then the Chinese word senses matching the English or Pinyin will be included in the TextSegment.Senses field.
func (DatabaseDocFinder) FindDocumentsInCol ¶ added in v0.0.17
func (df DatabaseDocFinder) FindDocumentsInCol(ctx context.Context, dictSearcher *dictionary.Searcher, parser QueryParser, query, col_gloss_file string) (*QueryResults, error)
FindDocumentsInCol returns a QueryResults object containing matching collections, documents, and dictionary words within a specific collecion. For dictionary lookup, a text segment will contains the QueryText searched for and possibly a matching dictionary entry. There will only be matching dictionary entries for Chinese words in the dictionary. If there are no Chinese words in the query then the Chinese word senses matching the English or Pinyin will be included in the TextSegment.Senses field.
func (DatabaseDocFinder) GetColMap ¶ added in v0.0.17
func (df DatabaseDocFinder) GetColMap() map[string]string
func (DatabaseDocFinder) GetDocFileMap ¶ added in v0.0.17
func (df DatabaseDocFinder) GetDocFileMap() map[string]string
func (DatabaseDocFinder) GetDocMap ¶ added in v0.0.17
func (df DatabaseDocFinder) GetDocMap() map[string]Document
func (DatabaseDocFinder) Inititialized ¶ added in v0.0.17
func (df DatabaseDocFinder) Inititialized() bool
type DictQueryParser ¶
type DictQueryParser struct{ Tokenizer tokenizer.DictTokenizer }
func (DictQueryParser) ParseQuery ¶
func (parser DictQueryParser) ParseQuery(query string) []TextSegment
The method for parsing the query text in this function is based on dictionary lookups
type DocFinder ¶ added in v0.0.17
type DocFinder interface { FindDocuments(ctx context.Context, dictSearcher *dictionary.Searcher, parser QueryParser, query string, advanced bool) (*QueryResults, error) FindDocumentsInCol(ctx context.Context, dictSearcher *dictionary.Searcher, parser QueryParser, query, col_gloss_file string) (*QueryResults, error) GetColMap() map[string]string GetDocMap() map[string]Document GetDocFileMap() map[string]string Inititialized() bool }
DocFinder finds documents.
type Document ¶
type QueryParser ¶
type QueryParser interface {
ParseQuery(query string) []TextSegment
}
Parses input queries into a slice of text segments
func MakeQueryParser ¶
func MakeQueryParser(dict map[string]dicttypes.Word) QueryParser
Creates a QueryParser
type QueryResults ¶
type QueryResults struct {
Query, CollectionFile string
NumCollections, NumDocuments int
Collections []Collection
Documents []Document
Terms []TextSegment
}
type TextSegment ¶
A text segment contains the QueryText searched for and possibly a matching dictionary entry. There will only be matching dictionary entries for Chinese words in the dictionary. Non-Chinese text, punctuation, and unknown Chinese words will have nil DictEntry values and matching values will be included in the Senses field.