Documentation
¶
Index ¶
- Variables
- type CacheMatcher
- type ChunkSource
- type Column
- type Data
- type Dictionary
- func (d *Dictionary) Add(entry *Entry)
- func (d *Dictionary) Delete(entry *Entry)
- func (d *Dictionary) Entries() []*Entry
- func (d *Dictionary) ExportDict(path string, columns []Column)
- func (d *Dictionary) Flush() (changed bool)
- func (d *Dictionary) Len() int
- func (d *Dictionary) ResetMatcher()
- func (d *Dictionary) Search(key string, useColumn Column, searchVersion int, ...)
- type Entry
- type FileEntries
- type MatchResult
- type MatchResultChunk
- type Matcher
- type ModifyType
- type YAML
Constants ¶
This section is empty.
Variables ¶
View Source
var ( YAML_BEGIN = "---" YAML_END = "..." )
View Source
var DEFAULT_COLUMNS = []Column{COLUMN_TEXT, COLUMN_WEIGHT, COLUMN_CODE, COLUMN_STEM}
Functions ¶
This section is empty.
Types ¶
type CacheMatcher ¶
type CacheMatcher struct {
// contains filtered or unexported fields
}
func (*CacheMatcher) Reset ¶
func (m *CacheMatcher) Reset()
func (*CacheMatcher) Search ¶
func (m *CacheMatcher) Search(key string, useColumn Column, searchVersion int, list []*Entry, resultChan chan<- MatchResultChunk, ctx context.Context)
type ChunkSource ¶
type ChunkSource struct {
// contains filtered or unexported fields
}
func (*ChunkSource) Len ¶
func (e *ChunkSource) Len() int
func (*ChunkSource) String ¶
func (e *ChunkSource) String(i int) string
type Column ¶
type Column string
func ParseInput ¶
Parse input string to a pair of strings 支持乱序输入,如 "你好 nau 1" 或 "nau 1 你好" 解析规则:将原始内容通过空白字符分割成单元,依次判断每个单元是否是汉字、纯数字、ascii, 汉字将作为text,纯数字作为weight,其他ascii根据顺序,前面的将用空格连结合并为code,最后的为stem stem(造字码,用于造词时代替code,比如 的 编码为 u,造字为 un,当造词 我的 时,会用un代替u,最终用tuun造词 我的)
type Data ¶
type Data struct {
Text string
Code string
Stem string
Weight int
// contains filtered or unexported fields
}
func (*Data) ResetColumns ¶
func (*Data) ToStringWithColumns ¶
type Dictionary ¶
type Dictionary struct {
// contains filtered or unexported fields
}
func NewDictionary ¶
func NewDictionary(fes []*FileEntries, matcher Matcher) *Dictionary
func (*Dictionary) Add ¶
func (d *Dictionary) Add(entry *Entry)
func (*Dictionary) Delete ¶
func (d *Dictionary) Delete(entry *Entry)
func (*Dictionary) Entries ¶
func (d *Dictionary) Entries() []*Entry
func (*Dictionary) ExportDict ¶
func (d *Dictionary) ExportDict(path string, columns []Column)
func (*Dictionary) Flush ¶
func (d *Dictionary) Flush() (changed bool)
func (*Dictionary) Len ¶
func (d *Dictionary) Len() int
func (*Dictionary) ResetMatcher ¶
func (d *Dictionary) ResetMatcher()
func (*Dictionary) Search ¶
func (d *Dictionary) Search(key string, useColumn Column, searchVersion int, resultChan chan<- MatchResultChunk, ctx context.Context)
type Entry ¶
type Entry struct {
FID uint8
// contains filtered or unexported fields
}
type FileEntries ¶
type FileEntries struct {
Err error
FilePath string
RawBs []byte
Entries []*Entry
Columns []Column
ID uint8
}
func LoadItems ¶
func LoadItems(paths ...string) (fes []*FileEntries)
func (*FileEntries) Cmp ¶
func (fe *FileEntries) Cmp(ofe any) bool
func (*FileEntries) Id ¶
func (fe *FileEntries) Id() int
func (*FileEntries) String ¶
func (fe *FileEntries) String() string
type MatchResult ¶
type MatchResult struct {
Entry *Entry
// contains filtered or unexported fields
}
func (*MatchResult) Cmp ¶
func (m *MatchResult) Cmp(other any) bool
func (*MatchResult) Id ¶
func (m *MatchResult) Id() int
func (*MatchResult) String ¶
func (m *MatchResult) String() string
type MatchResultChunk ¶
type MatchResultChunk struct {
Result []*MatchResult
Version int
}
type ModifyType ¶
type ModifyType int
const ( NC ModifyType = iota // default no change DELETE MODIFY // by ReRaw ADD // by NewEntryAdd )
Click to show internal directories.
Click to hide internal directories.