tagengine

package module
v0.0.0-...-a0b360c Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tokenize

func Tokenize(
	input string,
	maxNgram int,
) (
	tokens []string,
)

Types

type Match

type Match struct {
	Tag        string
	Confidence float64 // In the range (0,1].
}

type Rule

type Rule struct {
	Tag      string
	Includes []string
	Excludes []string
	Blocks   []string // List of blocked tags.

	MatchCount int
	FirstCount int
	// contains filtered or unexported fields
}

func NewRule

func NewRule(tag string) Rule

func (Rule) Block

func (r Rule) Block(l ...string) Rule

func (Rule) Exc

func (r Rule) Exc(l ...string) Rule

func (Rule) Inc

func (r Rule) Inc(l ...string) Rule

type RuleGroup

type RuleGroup struct {
	Tag      string
	Includes [][]string
	Excludes []string
	Blocks   []string
}

A RuleGroup can be converted into a list of rules. Each rule will point to the same tag, and have the same exclude set.

func NewRuleGroup

func NewRuleGroup(tag string) RuleGroup

func (RuleGroup) Block

func (g RuleGroup) Block(l ...string) RuleGroup

func (RuleGroup) Exc

func (g RuleGroup) Exc(l ...string) RuleGroup

func (RuleGroup) Inc

func (g RuleGroup) Inc(l ...string) RuleGroup

func (RuleGroup) ToList

func (rg RuleGroup) ToList() (l []Rule)

type RuleSet

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

func NewRuleSet

func NewRuleSet() *RuleSet

func NewRuleSetFromList

func NewRuleSetFromList(rules []Rule) *RuleSet

func (*RuleSet) Add

func (t *RuleSet) Add(ruleOrGroup ...interface{})

func (*RuleSet) AddRule

func (t *RuleSet) AddRule(rules ...Rule)

func (*RuleSet) AddRuleGroup

func (t *RuleSet) AddRuleGroup(ruleGroups ...RuleGroup)

func (*RuleSet) ListRules

func (t *RuleSet) ListRules() []*Rule

ListRules returns rules used in the ruleset sorted by the rules' FirstCount. This is the number of times the given rule was the best match to an input.

func (*RuleSet) Match

func (t *RuleSet) Match(input string) []Match

Return a list of matches with confidence.

func (*RuleSet) MatchRules

func (t *RuleSet) MatchRules(input string) (rules []*Rule)

MatchRules will return a list of all matching rules. The rules are sorted by the match's "score". The best match will be first.

Jump to

Keyboard shortcuts

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