rules

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: GPL-3.0 Imports: 6 Imported by: 4

Documentation

Overview

Package rules contains a few general validation rule types. The validation design and interfaces can be found in package validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIllegalOrthRe added in v0.4.1

func NewIllegalOrthRe(ss symbolset.SymbolSet, name string, level string, re string, msg string, accept []lex.Entry, reject []lex.Entry) (validation.Rule, error)

func NewIllegalTagRe added in v0.4.1

func NewIllegalTagRe(ss symbolset.SymbolSet, name string, level string, re string, msg string, accept []lex.Entry, reject []lex.Entry) (validation.Rule, error)

func NewIllegalTransRe added in v0.4.1

func NewIllegalTransRe(ss symbolset.SymbolSet, name string, level string, re string, msg string, accept []lex.Entry, reject []lex.Entry) (validation.Rule, error)

func NewRequiredOrthRe added in v0.4.1

func NewRequiredOrthRe(ss symbolset.SymbolSet, name string, level string, re string, msg string, accept []lex.Entry, reject []lex.Entry) (validation.Rule, error)

func NewRequiredTagRe added in v0.4.1

func NewRequiredTagRe(ss symbolset.SymbolSet, name string, level string, re string, msg string, accept []lex.Entry, reject []lex.Entry) (validation.Rule, error)

func NewRequiredTransRe added in v0.4.1

func NewRequiredTransRe(ss symbolset.SymbolSet, name string, level string, re string, msg string, accept []lex.Entry, reject []lex.Entry) (validation.Rule, error)

func ProcessRe added in v0.4.1

func ProcessRe(Regexp string) (*regexp2.Regexp, error)

ProcessRe converts an input regexp string to a compiled regexp2 regular expression

func ProcessTransRe

func ProcessTransRe(SymbolSet symbolset.SymbolSet, Regexp string) (*regexp2.Regexp, error)

ProcessTransRe converts pre-defined entities to the appropriate symbols. Strings replaced are: syllabic, nonsyllabic, phoneme, symbol.

Types

type Decomp2Orth

type Decomp2Orth struct {
	CompDelim               string
	AcceptEmptyDecomp       bool
	PreFilterWordPartString func(string) (string, error)
	Accept                  []lex.Entry
	Reject                  []lex.Entry
}

Decomp2Orth is a general rule type to validate the word parts vs. the orthography. A filter is used to control the filtering, typically how to treat triple consonants at boundaries.

func (Decomp2Orth) Level

func (r Decomp2Orth) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (Decomp2Orth) Name

func (r Decomp2Orth) Name() string

Name is the name of this rule

func (Decomp2Orth) ShouldAccept

func (r Decomp2Orth) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (Decomp2Orth) ShouldReject

func (r Decomp2Orth) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (Decomp2Orth) Validate

func (r Decomp2Orth) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

type EmptyRule added in v0.4.1

type EmptyRule struct {
	NameStr string
	Accept  []lex.Entry
	Reject  []lex.Entry
}

func (EmptyRule) Level added in v0.4.1

func (r EmptyRule) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (EmptyRule) Name added in v0.4.1

func (r EmptyRule) Name() string

Name is the name of this rule

func (EmptyRule) ShouldAccept added in v0.4.1

func (r EmptyRule) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (EmptyRule) ShouldReject added in v0.4.1

func (r EmptyRule) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (EmptyRule) Validate added in v0.4.1

func (r EmptyRule) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

type IllegalOrthRe added in v0.4.1

type IllegalOrthRe struct {
	NameStr  string
	LevelStr string
	Message  string
	Re       *regexp2.Regexp
	Accept   []lex.Entry
	Reject   []lex.Entry
}

IllegalOrthRe is a general rule type to check for illegal orthographies by regexp

func (IllegalOrthRe) Level added in v0.4.1

func (r IllegalOrthRe) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (IllegalOrthRe) Name added in v0.4.1

func (r IllegalOrthRe) Name() string

Name is the name of this rule

func (IllegalOrthRe) ShouldAccept added in v0.4.1

func (r IllegalOrthRe) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (IllegalOrthRe) ShouldReject added in v0.4.1

func (r IllegalOrthRe) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (IllegalOrthRe) Validate added in v0.4.1

func (r IllegalOrthRe) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

type IllegalTagRe added in v0.4.1

type IllegalTagRe struct {
	NameStr  string
	LevelStr string
	Message  string
	Re       *regexp2.Regexp
	Accept   []lex.Entry
	Reject   []lex.Entry
}

IllegalTagRe is a general rule type to check for illegal tag by regexp

func (IllegalTagRe) Level added in v0.4.1

func (r IllegalTagRe) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (IllegalTagRe) Name added in v0.4.1

func (r IllegalTagRe) Name() string

Name is the name of this rule

func (IllegalTagRe) ShouldAccept added in v0.4.1

func (r IllegalTagRe) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (IllegalTagRe) ShouldReject added in v0.4.1

func (r IllegalTagRe) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (IllegalTagRe) Validate added in v0.4.1

func (r IllegalTagRe) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

type IllegalTransRe

type IllegalTransRe struct {
	NameStr  string
	LevelStr string
	Message  string
	Re       *regexp2.Regexp
	Accept   []lex.Entry
	Reject   []lex.Entry
}

IllegalTransRe is a general rule type to check for illegal transcriptions by regexp

func (IllegalTransRe) Level

func (r IllegalTransRe) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (IllegalTransRe) Name

func (r IllegalTransRe) Name() string

Name is the name of this rule

func (IllegalTransRe) ShouldAccept

func (r IllegalTransRe) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (IllegalTransRe) ShouldReject

func (r IllegalTransRe) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (IllegalTransRe) Validate

func (r IllegalTransRe) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

type MustHaveTrans

type MustHaveTrans struct {
	Accept []lex.Entry
	Reject []lex.Entry
}

MustHaveTrans is a general rule to make sure each entry has at least one transcription

func (MustHaveTrans) Level

func (r MustHaveTrans) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (MustHaveTrans) Name

func (r MustHaveTrans) Name() string

Name is the name of this rule

func (MustHaveTrans) ShouldAccept

func (r MustHaveTrans) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (MustHaveTrans) ShouldReject

func (r MustHaveTrans) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (MustHaveTrans) Validate

func (r MustHaveTrans) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

type NoEmptyTrans

type NoEmptyTrans struct {
	Accept []lex.Entry
	Reject []lex.Entry
}

NoEmptyTrans is a general rule to make sure no transcriptions are be empty

func (NoEmptyTrans) Level

func (r NoEmptyTrans) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (NoEmptyTrans) Name

func (r NoEmptyTrans) Name() string

Name is the name of this rule

func (NoEmptyTrans) ShouldAccept

func (r NoEmptyTrans) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (NoEmptyTrans) ShouldReject

func (r NoEmptyTrans) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (NoEmptyTrans) Validate

func (r NoEmptyTrans) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

type RequiredOrthRe added in v0.4.1

type RequiredOrthRe struct {
	NameStr  string
	LevelStr string
	Message  string
	Re       *regexp2.Regexp
	Accept   []lex.Entry
	Reject   []lex.Entry
}

RequiredOrthRe is a general rule type used to defined basic orthography requirements using regexps

func (RequiredOrthRe) Level added in v0.4.1

func (r RequiredOrthRe) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (RequiredOrthRe) Name added in v0.4.1

func (r RequiredOrthRe) Name() string

Name is the name of this rule

func (RequiredOrthRe) ShouldAccept added in v0.4.1

func (r RequiredOrthRe) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (RequiredOrthRe) ShouldReject added in v0.4.1

func (r RequiredOrthRe) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (RequiredOrthRe) Validate added in v0.4.1

func (r RequiredOrthRe) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

type RequiredTagRe added in v0.4.1

type RequiredTagRe struct {
	NameStr  string
	LevelStr string
	Message  string
	Re       *regexp2.Regexp
	Accept   []lex.Entry
	Reject   []lex.Entry
}

RequiredTagRe is a general rule type used to defined basic tag requirements using regexps

func (RequiredTagRe) Level added in v0.4.1

func (r RequiredTagRe) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (RequiredTagRe) Name added in v0.4.1

func (r RequiredTagRe) Name() string

Name is the name of this rule

func (RequiredTagRe) ShouldAccept added in v0.4.1

func (r RequiredTagRe) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (RequiredTagRe) ShouldReject added in v0.4.1

func (r RequiredTagRe) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (RequiredTagRe) Validate added in v0.4.1

func (r RequiredTagRe) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

type RequiredTransRe

type RequiredTransRe struct {
	NameStr  string
	LevelStr string
	Message  string
	Re       *regexp2.Regexp
	Accept   []lex.Entry
	Reject   []lex.Entry
}

RequiredTransRe is a general rule type used to defined basic transcription requirements using regexps

func (RequiredTransRe) Level

func (r RequiredTransRe) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (RequiredTransRe) Name

func (r RequiredTransRe) Name() string

Name is the name of this rule

func (RequiredTransRe) ShouldAccept

func (r RequiredTransRe) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (RequiredTransRe) ShouldReject

func (r RequiredTransRe) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (RequiredTransRe) Validate

func (r RequiredTransRe) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

type SymbolSetRule

type SymbolSetRule struct {
	SymbolSet symbolset.SymbolSet
	Accept    []lex.Entry
	Reject    []lex.Entry
}

SymbolSetRule is a general rule for verifying that each phoneme is a legal symbol

func (SymbolSetRule) Level

func (r SymbolSetRule) Level() string

Level is the rule level (typically format, fatal, warning, info)

func (SymbolSetRule) Name

func (r SymbolSetRule) Name() string

Name is the name of this rule

func (SymbolSetRule) ShouldAccept

func (r SymbolSetRule) ShouldAccept() []lex.Entry

ShouldAccept returns a slice of entries that the rule should accept

func (SymbolSetRule) ShouldReject

func (r SymbolSetRule) ShouldReject() []lex.Entry

ShouldReject returns a slice of entries that the rule should reject

func (SymbolSetRule) Validate

func (r SymbolSetRule) Validate(e lex.Entry) (validation.Result, error)

Validate a lex.Entry

Jump to

Keyboard shortcuts

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