sources

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: GPL-3.0 Imports: 15 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 []string `json:"dicts"`
}

type Dict

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

type Dicts added in v0.0.6

type Dicts []*MdxDict

func (*Dicts) Load added in v0.0.6

func (g *Dicts) Load() error

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 {
	// For personal usage example, "oald9.json", or "Longman Dictionary of Contemporary English"
	MdxFile string
	// Only match the mdx with the same mdxFile name
	MdxCss  string
	MdxDict Dict
	// contains filtered or unexported fields
}

func (*MdxDict) CSS

func (d *MdxDict) CSS() string

func (*MdxDict) Get

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

func (*MdxDict) Register

func (d *MdxDict) Register() error

type RawOutput

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

type Searcher

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

func New

func New(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