bmpm

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accuracy

type Accuracy string

Accuracy exact or approximate matching

const (
	Exact  Accuracy = "exact"  // exact matching rules
	Approx Accuracy = "approx" // approx matching (results in more tokens)
)

type DetectLangFunc

type DetectLangFunc = func(input string) Lang

type FinalRule

type FinalRule struct {
	First  Rules
	Second map[Lang]Rules
}

type FinalRules

type FinalRules struct {
	Approx FinalRule
	Exact  FinalRule
}

type Lang

type Lang int64
const (
	LangUnitialized Lang = -1
	LangInvalid     Lang = 0
	LangAny         Lang = 1
)

type LangRule

type LangRule struct {
	Matcher *Matcher
	Langs   Lang
	Accept  bool
}

type Matcher

type Matcher struct {
	MatchEmptyString bool
	Pattern          *regexp.Regexp
	Prefix           [][]rune
	Suffix           [][]rune
	Contains         [][]rune
	Exact            [][]rune
}

func (Matcher) Match

func (r Matcher) Match(str []rune) bool

type Mode

type Mode string

Mode which name mode to use for matching

const (
	Generic   Mode = "generic"   // for general usage
	Ashkenazi Mode = "ashkenazi" // for ashkenazi names
	Sephardic Mode = "sephardic" // for sephardic names
)

func (Mode) Valid

func (m Mode) Valid() bool

type Rule

type Rule struct {
	Pattern      []rune
	LeftContext  *Matcher
	RightContext *Matcher
	Phonetic     []RuleToken
}

func (Rule) ApplyTo

func (r Rule) ApplyTo(input []rune, position int) (result []RuleToken, offset int)

type RuleToken

type RuleToken struct {
	Text  []rune
	Langs Lang
}

type Rules

type Rules []Rule

func (Rules) Apply

func (r Rules) Apply(input *Tokens, lang Lang, ignoreLangs bool) *Tokens

type Ruleset

type Ruleset struct {
	Main       Rules
	Final1     Rules
	Final2     Rules
	Discards   []string
	DetectLang DetectLangFunc
}

type Token

type Token struct {
	ID    int
	Langs Lang
}

type Tokens

type Tokens struct {
	Items []Token
	Buf   *exrunes.Buffer
}

func MakeTokens

func MakeTokens(input string, mode Mode, accuracy Accuracy, ruleset Ruleset, lang Lang, concat bool, buf *exrunes.Buffer) *Tokens

func (*Tokens) Add

func (t *Tokens) Add(data []rune, langs Lang)

func (*Tokens) Deduplicate

func (t *Tokens) Deduplicate()

func (*Tokens) Iterate

func (t *Tokens) Iterate(iter func(s []rune) bool)

func (*Tokens) Len

func (t *Tokens) Len() int

func (*Tokens) MergeRules

func (t *Tokens) MergeRules(rules []RuleToken, lang Lang)

Jump to

Keyboard shortcuts

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