migemo

package
v0.0.0-...-2cc85a8 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2021 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(d Dict, s string) (*regexp.Regexp, error)

Compile compiles a regexp which expanded from string s with Migemo.

func DefaultDictdir

func DefaultDictdir() string

DefaultDictdir returns default dictonary directory.

func NewRegexp

func NewRegexp(m Matcher) (*regexp.Regexp, error)

NewRegexp generates a regexp from matcher.

func Pattern

func Pattern(d Dict, s string) (string, error)

Pattern generates a regexp patter string from string s with Migemo.

Types

type AssetProc

type AssetProc func(io.Reader) error

AssetProc is a function to proceed asset's io.Reader.

type Assets

type Assets interface {
	Get(name string, proc AssetProc) error
}

Assets provides assets collection, which can be obtained by Get.

type Dict

type Dict interface {
	Matcher(string) (Matcher, error)
}

Dict provides an interface of dictionary for Migemo.

func Load

func Load(path string) (Dict, error)

Load loads a dict from path (file system).

func LoadAssets

func LoadAssets(assets Assets) (Dict, error)

LoadAssets loads a dict from Assets.

func LoadDefault

func LoadDefault() (Dict, error)

LoadDefault loads a dictionary with default dictdir.

type Match

type Match struct {
	Start, End int
}

Match is positional information of a match.

type Matcher

type Matcher interface {
	// Match matches with string.
	Match(string) (chan Match, error)
	// Pattern provides a regexp pattern of this match.
	Pattern() (string, error)
	// SetOptions changes matcher's options.
	SetOptions(MatcherOptions)
	// GetOptions retrieves matcher's options.
	GetOptions() MatcherOptions
}

Matcher defines Migemo matcher interface, which have an expanded migemo tree and provides matching operations.

type MatcherOptions

type MatcherOptions struct {
	OpOr                  string
	OpGroupIn, OpGroupOut string
	OpClassIn, OpClassOut string
	OpWSpaces             string
}

MatcherOptions defines options for migemo matcher (generation of regexp).

type PathAssets

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

PathAssets is an implementation of Assets interface with physical file system (path).

func (*PathAssets) Get

func (a *PathAssets) Get(name string, proc AssetProc) error

Get obtains an asset by name and proceed it with proc.

Jump to

Keyboard shortcuts

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