sources

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Aho–Corasick algorithm Refer to https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm https://www.youtube.com/watch?v=O7_w001f58c https://www.youtube.com/watch?v=OFKxWFew_L0

package sources defines the interface of a "dictionary", input a _string_, get the RAW content in the dictionary, might include the definitions/css files/renderers/...

Index

Constants

This section is empty.

Variables

View Source
var G = &Dicts{}
View Source
var Gbold = "**"
View Source
var Gitalic = "*"

Functions

func GetFromLDOCE

func GetFromLDOCE(word string) string

func LoadConfig

func LoadConfig() error

func QueryByURL

func QueryByURL(word string) string

func QueryMDX

func QueryMDX(word string, f string) string

func Restore

func Restore()

func Store

func Store()

Types

type AhoCorasick

type AhoCorasick struct {
	// contains filtered or unexported fields
}

func (*AhoCorasick) GetRawOutputs

func (ack *AhoCorasick) GetRawOutputs(input string) []RawOutput

type Config

type Config struct {
	Dicts []DictConfig `json:"dicts"`
}

type DBDict added in v0.3.0

type DBDict struct {
}

func (*DBDict) Get added in v0.3.0

func (d *DBDict) Get(s string) string

func (*DBDict) Keys added in v0.3.0

func (d *DBDict) Keys() []string

func (*DBDict) WordsWithPrefix added in v0.3.0

func (d *DBDict) WordsWithPrefix(prefix string) []string

type DBIExact added in v0.3.0

type DBIExact struct {
}

IExact is a case in-sensitive search source, no other fuzzy searching algos.

func (*DBIExact) GetRawOutputs added in v0.3.0

func (e *DBIExact) GetRawOutputs(input string) []RawOutput

type Dict

type Dict interface {
	Keys() []string
	Get(string) string
}

type DictConfig added in v0.0.7

type DictConfig struct {
	Name string
	Css  string
	Type string
}

type Dicts added in v0.0.6

type Dicts []*MdxDict

func (*Dicts) Load added in v0.0.6

func (g *Dicts) Load(fzf bool, mdd bool, lazy bool) error

type Exact added in v0.0.7

type Exact struct {
	// contains filtered or unexported fields
}

Exact is a case sensitive search source, only matching the key(s) that is "exactly" the same

func (*Exact) GetRawOutputs added in v0.0.7

func (e *Exact) GetRawOutputs(input string) []RawOutput

type IExact added in v0.2.0

type IExact struct {
	// contains filtered or unexported fields
}

IExact is a case in-sensitive search source, no other fuzzy searching algos.

func (*IExact) GetRawOutputs added in v0.2.0

func (e *IExact) GetRawOutputs(input string) []RawOutput

type Map

type Map map[string]string

func (Map) Get

func (m Map) Get(word string) string

func (Map) Keys

func (m Map) Keys() []string

type MdxDict

type MdxDict struct {
	// SourceType
	Type string
	// For personal usage example, "oald9.json", or "Longman Dictionary of Contemporary English"
	MdxFile string
	MdxDict Dict // TODO: it's "embedded" in the searcher, maybe we can remove it to reduce mem usage when apply non-plain search algorithms.
	// contains filtered or unexported fields
}

func (*MdxDict) Get

func (d *MdxDict) Get(word string) []string

func (*MdxDict) Register

func (d *MdxDict) Register(fzf bool, mdd bool, lazy bool) error

TODO: make the option easier to maintain.

type RawOutput

type RawOutput interface {
	GetMatch() string
	GetDefinition() string
}

type Searcher

type Searcher interface {
	GetRawOutputs(string) []RawOutput
}

func NewAho added in v0.0.7

func NewAho(dict Dict) Searcher

func NewDBIExact added in v0.3.0

func NewDBIExact() Searcher

func NewExact added in v0.0.7

func NewExact(dict Dict) Searcher

func NewIExact added in v0.2.0

func NewIExact(dict Dict) Searcher

type Source

type Source interface {
	Register() error
	Get(string) []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL