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
|
2020-01-09 01:21:09 +01:00
|
|
|
func (rules LabelRules) Find(label string) LabelRule {
|
|
|
|
if rule, ok := rules[label]; ok {
|
|
|
|
return rule
|
|
|
|
}
|
|
|
|
|
|
|
|
return LabelRule{Threshold: 0.1}
|
|
|
|
}
|