Adjust rule Do not redact genitive CBI_author

This commit is contained in:
lmaldacker 2021-02-10 14:17:26 +01:00
parent 6d9ed080ce
commit c16f583ce1

View File

@ -139,6 +139,33 @@ public class Section {
});
}
public void dismissByRegEx(String type, String pattern, boolean patternCaseInsensitive, int group, int ruleNumber, String reason) {
Pattern compiledPattern = Patterns.getCompiledPattern(pattern, patternCaseInsensitive);
Set<Entity> expanded = new HashSet<>();
for (Entity entity : entities) {
if (!entity.getType().equals(type) || entity.getTextAfter() == null) {
continue;
}
Matcher matcher = compiledPattern.matcher(entity.getTextAfter());
while (matcher.find()) {
String match = matcher.group(group);
if (StringUtils.isNotBlank(match)) {
entity.setRedaction(false);
entity.setMatchedRule(ruleNumber);
entity.setRedactionReason(reason);
}
}
}
EntitySearchUtils.addEntitiesWithHigherRank(entities, expanded, dictionary);
EntitySearchUtils.removeEntitiesContainedInLarger(entities);
}
public void redactIfPrecededBy(String prefix, String type, int ruleNumber, String reason, String legalBasis) {