feat(rules): add the aggressive deadline option to nl and br
This commit is contained in:
1 parent
b80ddbf523
commit
c2384ff7ad
4 files changed
+66
-4
No files matched your search
+13
-2
@@ -11,12 +11,23 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func Deadline(s rules.Strategy) rules.Rule {
|
||||
// DeadlineOptions configures the Deadline rule.
|
||||
type DeadlineOptions struct {
|
||||
// Aggressive makes the "binnen"/"in"/"over"/"na" prefix optional, so "3 dagen" matches too.
|
||||
Aggressive bool
|
||||
}
|
||||
|
||||
func Deadline(s rules.Strategy, opts ...DeadlineOptions) rules.Rule {
|
||||
overwrite := s == rules.Override
|
||||
|
||||
prefix := "(binnen|in|over|na)"
|
||||
if len(opts) > 0 && opts[0].Aggressive {
|
||||
prefix += "?"
|
||||
}
|
||||
|
||||
return &rules.F{
|
||||
RegExp: regexp.MustCompile(
|
||||
"(?i)(?:\\W|^)(binnen|in|over|na)\\s*" +
|
||||
"(?i)(?:\\W|^)" + prefix + "\\s*" +
|
||||
"(" + INTEGER_WORDS_PATTERN + "|[0-9]+|een(?:\\s*(paar|half|halve))?)\\s*" +
|
||||
"(seconden?|minuut|minuten|uur|uren|dag|dagen|week|weken|maand|maanden|jaar|jaren)\\s*" +
|
||||
"(?:\\W|$)"),
|
||||
|
||||
Reference in new issue
Block a user