repochecker/grammalecte: Refactor grammar passage extraction
This commit is contained in:
parent
ccc2c5d1d7
commit
2381dfe4f5
2 changed files with 25 additions and 10 deletions
|
@ -183,19 +183,11 @@ func grammalecte(name string, text string, paragraph int, exceptions *sync.Check
|
|||
}
|
||||
|
||||
for _, gerror := range data.GrammarErrors {
|
||||
if data.Text[0] == '>' && gerror.RuleId == "poncfin_règle1" {
|
||||
continue
|
||||
}
|
||||
|
||||
if gerror.RuleId == "mc_mot_composé" && ((gerror.End+1 < len(data.Text) && gerror.Start+1 < len(data.Text) && exceptions.HasException(fmt.Sprintf(":spelling:%s", data.Text[gerror.Start+1:gerror.End+1]))) || exceptions.HasException(fmt.Sprintf(":spelling:%s", data.Text[gerror.Start:gerror.End]))) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (paragraph == 0 && exceptions.HasException(fmt.Sprintf(":%d:%s", data.Paragraph, gerror.RuleId))) || (paragraph < 0 && exceptions.HasException(fmt.Sprintf(":%s", gerror.RuleId))) || (paragraph > 0 && exceptions.HasException(fmt.Sprintf(":%d:%s", paragraph, gerror.RuleId))) {
|
||||
continue
|
||||
}
|
||||
|
||||
errs = append(errs, lib.GrammarError{
|
||||
err := lib.GrammarError{
|
||||
Prefix: name,
|
||||
Source: data.Text,
|
||||
NSource: data.Paragraph,
|
||||
|
@ -206,7 +198,13 @@ func grammalecte(name string, text string, paragraph int, exceptions *sync.Check
|
|||
Message: gerror.Message,
|
||||
Suggestions: gerror.Suggestions,
|
||||
URL: gerror.URL,
|
||||
})
|
||||
}
|
||||
|
||||
if err.RuleId == "mc_mot_composé" && exceptions.HasException(fmt.Sprintf(":spelling:%s", err.GetPassage())) {
|
||||
continue
|
||||
}
|
||||
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue