Documentation
¶
Index ¶
- func CreateMySQLTable(conf *DatabaseConf) error
- func GetCurrentAbPath() string
- func SortedSkipList() string
- type DatabaseConf
- type DefaultResultWriter
- type Option
- type Result
- type ResultWriter
- type Search
- func File(filename string, skip ...string) (search *Search, err error)
- func MySQL(conf *DatabaseConf, skip ...string) (search *Search, err error)
- func Network(pageUrl string, skip ...string) (search *Search, err error)
- func NewSearch(opts ...Option) *Search
- func Strings(words []string, skip ...string) *Search
- type SensitiveWord
- type Skip
- type TrieWriter
- func (t *TrieWriter) Array() []string
- func (t *TrieWriter) BuildFail() int
- func (t *TrieWriter) Insert(word string) *TrieWriter
- func (t *TrieWriter) InsertBytes(p []byte, delim byte) (n int)
- func (t *TrieWriter) InsertFile(filename string)
- func (t *TrieWriter) InsertReader(reader io.Reader, delim byte) (n int, err error)
- func (t *TrieWriter) InsertScanner(scanner *bufio.Scanner)
- func (t *TrieWriter) InsertWords(words []string) *TrieWriter
- func (t *TrieWriter) Size() int
- func (t *TrieWriter) Skip() *Skip
- func (t *TrieWriter) String() string
- func (t *TrieWriter) WriteString(s string) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMySQLTable ¶
func CreateMySQLTable(conf *DatabaseConf) error
func SortedSkipList ¶
func SortedSkipList() string
Types ¶
type DatabaseConf ¶
type DefaultResultWriter ¶
type DefaultResultWriter struct {
// contains filtered or unexported fields
}
func (*DefaultResultWriter) Len ¶
func (_this *DefaultResultWriter) Len() int
func (*DefaultResultWriter) List ¶
func (_this *DefaultResultWriter) List() []*Result
func (*DefaultResultWriter) MarshalJSON ¶
func (_this *DefaultResultWriter) MarshalJSON() ([]byte, error)
func (*DefaultResultWriter) String ¶
func (_this *DefaultResultWriter) String() string
func (*DefaultResultWriter) Write ¶
func (_this *DefaultResultWriter) Write(res *Result) (stop bool)
type Option ¶
type Option func(options *options)
func SetSortedRunesSkip ¶
func SetSortedSkip ¶
func SetWriter ¶
func SetWriter(w *TrieWriter) Option
type Result ¶
type ResultWriter ¶
type Search ¶
type Search struct {
// contains filtered or unexported fields
}
Search 表示一个 tireRoot 树的搜索器
func (*Search) ReplaceRune ¶
ReplaceRune 将字节数组 s 中的所有敏感词替换为 new 并返回替换后的字节数组
func (*Search) TrieWriter ¶
func (_this *Search) TrieWriter() *TrieWriter
TrieWriter 返回关联的 TrieWriter
type SensitiveWord ¶
type Skip ¶
type Skip struct {
// contains filtered or unexported fields
}
func (*Skip) ShouldSkip ¶
type TrieWriter ¶
type TrieWriter struct {
// contains filtered or unexported fields
}
TrieWriter 表示一个Trie写入器,包含了一些trie树的相关操作。
func NewTrieWriter ¶
func NewTrieWriter() *TrieWriter
NewTrieWriter 返回一个新的TrieWriter对象,其中tireRoot属性为一个空的trie树根节点。
func (*TrieWriter) Array ¶ added in v0.2.6
func (t *TrieWriter) Array() []string
func (*TrieWriter) BuildFail ¶
func (t *TrieWriter) BuildFail() int
BuildFail 用于构建trie树中每个节点的失败指针,返回当前对象。
func (*TrieWriter) Insert ¶
func (t *TrieWriter) Insert(word string) *TrieWriter
Insert 向trie树中插入一个单词,返回当前对象。
func (*TrieWriter) InsertBytes ¶ added in v0.2.4
func (t *TrieWriter) InsertBytes(p []byte, delim byte) (n int)
InsertBytes 将一个字节数组写入到trie树中,返回写入的字节数和nil错误。在遍历字节数组的过程中,跳过被定义在skip属性中的字符,如果遇到换行符则在该单词的结尾节点标记为end
func (*TrieWriter) InsertFile ¶ added in v0.2.4
func (t *TrieWriter) InsertFile(filename string)
func (*TrieWriter) InsertReader ¶ added in v0.2.9
func (*TrieWriter) InsertScanner ¶ added in v0.2.5
func (t *TrieWriter) InsertScanner(scanner *bufio.Scanner)
func (*TrieWriter) InsertWords ¶
func (t *TrieWriter) InsertWords(words []string) *TrieWriter
InsertWords 向trie树中插入一个字符串数组中的所有单词,返回当前对象。调用了Insert(word string)方法。
func (*TrieWriter) String ¶
func (t *TrieWriter) String() string
func (*TrieWriter) WriteString ¶
func (t *TrieWriter) WriteString(s string) (n int, err error)
WriteString 将一个字符串写入到trie树中,返回写入的字节数和nil错误。调用了Insert(word string)方法。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.