1
0
forked from JOJ/JOJ3

feat(parser/keyword): max match count

This commit is contained in:
张泊明518370910136 2024-11-01 03:31:04 -04:00
parent 5de4c3ee78
commit 03c2819d25
Signed by untrusted user: 张泊明518370910136
GPG Key ID: D47306D7062CDA9D

View File

@ -8,8 +8,9 @@ import (
)
type Match struct {
Keyword string
Score int
Keyword string
Score int
MaxMatchCount int
}
type Conf struct {
@ -33,6 +34,9 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) (
content := executorResult.Files[file]
for _, match := range conf.Matches {
count := strings.Count(content, match.Keyword)
if match.MaxMatchCount > 0 {
count = min(count, match.MaxMatchCount)
}
if count > 0 {
matched = true
score -= count * match.Score