dictionary

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: Apache-2.0 Imports: 11 Imported by: 5

Documentation

Overview

Chinese-English dictionary database functions

Package for looking up words and multiword expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDBCon added in v0.0.5

func InitDBCon() (*sql.DB, error)

func LoadDict

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

Loads all words from the database

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

Initialize SQL statements

func (*Searcher) DatabaseInitialized added in v0.0.12

func (searcher *Searcher) DatabaseInitialized() bool

Returns the word senses with English approximate or Pinyin exact match

func (*Searcher) FindWordsByEnglish added in v0.0.5

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

Returns the word senses with English approximate or Pinyin exact match

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

Jump to

Keyboard shortcuts

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