2020-01-09 01:21:09 +01:00
|
|
|
package classify
|
|
|
|
|
2020-02-21 01:14:45 +01:00
|
|
|
// LabelRule defines the rule for a given Label
|
2020-01-09 01:21:09 +01:00
|
|
|
type LabelRule struct {
|
|
|
|
Label string
|
|
|
|
Threshold float32
|
|
|
|
Categories []string
|
|
|
|
Priority int
|
|
|
|
}
|
|
|
|
|
2020-02-21 01:14:45 +01:00
|
|
|
// LabelRules is a map of rules with label name as index
|
2020-01-09 01:21:09 +01:00
|
|
|
type LabelRules map[string]LabelRule
|
|
|
|
|
2020-02-21 01:14:45 +01:00
|
|
|
// Find is a getter for LabelRules that give a default rule with a non-zero threshold for missing keys
|
2021-02-21 17:18:36 +01:00
|
|
|
func (rules LabelRules) Find(label string) (rule LabelRule, ok bool) {
|
2020-01-09 01:21:09 +01:00
|
|
|
if rule, ok := rules[label]; ok {
|
2021-02-21 17:18:36 +01:00
|
|
|
return rule, true
|
2020-01-09 01:21:09 +01:00
|
|
|
}
|
|
|
|
|
2021-02-21 17:18:36 +01:00
|
|
|
return LabelRule{Threshold: 0.1}, false
|
2020-01-09 01:21:09 +01:00
|
|
|
}
|