dictionary

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Overview

Chinese-English dictionary database search functions

Package for looking up words and multiword expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadDict

func LoadDict(ctx context.Context, database *sql.DB,
	appConfig config.AppConfig) (map[string]dicttypes.Word, error)

LoadDict loads all words from the database

func ValidateDict added in v0.0.18

func ValidateDict(wdict map[string]dicttypes.Word, validator Validator) error

ValidateDict check the Chinese-English for errors

Types

type Results

type Results struct {
	Words []dicttypes.Word
}

Encapsulates term lookup recults

type Searcher added in v0.0.5

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

Searcher looks up Chinese words by either Chinese or English.

If the dictionary searcher cannot connect to the database then it will run in degraded mode by looking up Chinese words form dictionary file.

func NewSearcher added in v0.0.5

func NewSearcher(ctx context.Context, database *sql.DB) *Searcher

NewSearcher initialize SQL statements

func (*Searcher) FindWordsByEnglish added in v0.0.5

func (searcher *Searcher) FindWordsByEnglish(ctx context.Context,
	query string) ([]dicttypes.WordSense, error)

FindWordsByEnglish returns the word senses with English approximate or Pinyin exact match

func (*Searcher) Initialized added in v0.0.17

func (s *Searcher) Initialized() bool

Initialized returns true if there were no error in initialization.

func (*Searcher) LookupSubstr added in v0.0.5

func (searcher *Searcher) LookupSubstr(ctx context.Context,
	query, topic_en, subtopic_en string) (*Results, error)

Lookup a term based on a substring and a topic

type Validator added in v0.0.18

type Validator interface {
	Validate(pos, domain string) error
}

Performs validation of dictionary entries. Use NewValidator to create a Validator.

func NewValidator added in v0.0.18

func NewValidator(posReader io.Reader, domainReader io.Reader) (Validator, error)

Crates a Validator with the given readers Params:

posReader Reader to load the valid parts of speech from
domainReader Reader to load the valid subject domains

Returns:

An initialized Validator

Jump to

Keyboard shortcuts

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