Generates stoplist from YAML-format
Supports:
- Regexp patterns
- AND/OR conditions
- References
go get 'github.com/webtor-io/stoplist'
package main
import (
"log"
"github.com/webtor-io/stoplist"
)
var rules = `
main:
- abra
- cadabra
`
func main() error {
r, err := stoplist.NewRuleFromYaml([]byte(rules))
if err != nil {
return err
}
res := r.Check("abra cadabra")
log.Println(res)
return nil
}
- YAML must have
main
key - it is starting point - Every key must have an array of rules and all these rules will be used with OR condition, like:
main:
- rule1
- rule2
- ...
- All keys can be referenced with curly brackets, like:
rule:
- something
main:
- {rule}
- Regular expression must be enclosed with slashes, like:
main:
- /\d+/
- OR condition is represented with pipe
|
, like:
main:
- aaa|bbb|ccc
- AND condition is represented with plus
+
, like:
main:
- aaa+bbb+ccc