Pull request #224: RED-2125: Enabled possibility to reference annotations in rules
Merge in RED/redaction-service from RED-2125 to master * commit '6f930b18133286289e330adbbbf390671b63d1b5': RED-2125: Enabled possibility to reference annotations in rules
This commit is contained in:
commit
16b06c2fc5
@ -2,6 +2,6 @@ package com.iqser.red.service.redaction.v1.model;
|
|||||||
|
|
||||||
public enum ArgumentType {
|
public enum ArgumentType {
|
||||||
|
|
||||||
INTEGER, BOOLEAN, STRING, FILE_ATTRIBUTE, REGEX, TYPE, RULE_NUMBER, LEGAL_BASIS
|
INTEGER, BOOLEAN, STRING, FILE_ATTRIBUTE, REGEX, TYPE, RULE_NUMBER, LEGAL_BASIS, REFERENCE_TYPE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,6 +64,8 @@ public class RedactionLogEntry {
|
|||||||
|
|
||||||
private Set<Engine> engines= new HashSet<>();
|
private Set<Engine> engines= new HashSet<>();
|
||||||
|
|
||||||
|
private Set<String> reference = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,11 +44,13 @@ public class Entity implements ReasonHolder {
|
|||||||
|
|
||||||
private Set<Engine> engines = new HashSet<>();
|
private Set<Engine> engines = new HashSet<>();
|
||||||
|
|
||||||
|
private Set<Entity> references = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
public Entity(String word, String type, boolean redaction, String redactionReason,
|
public Entity(String word, String type, boolean redaction, String redactionReason,
|
||||||
List<EntityPositionSequence> positionSequences, String headline, int matchedRule, int sectionNumber,
|
List<EntityPositionSequence> positionSequences, String headline, int matchedRule, int sectionNumber,
|
||||||
String legalBasis, boolean isDictionaryEntry, String textBefore, String textAfter, Integer start,
|
String legalBasis, boolean isDictionaryEntry, String textBefore, String textAfter, Integer start,
|
||||||
Integer end, boolean isDossierDictionaryEntry, Set<Engine> engines) {
|
Integer end, boolean isDossierDictionaryEntry, Set<Engine> engines, Set<Entity> references) {
|
||||||
|
|
||||||
this.word = word;
|
this.word = word;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -66,6 +68,7 @@ public class Entity implements ReasonHolder {
|
|||||||
this.end = end;
|
this.end = end;
|
||||||
this.isDossierDictionaryEntry = isDossierDictionaryEntry;
|
this.isDossierDictionaryEntry = isDossierDictionaryEntry;
|
||||||
this.engines = engines;
|
this.engines = engines;
|
||||||
|
this.references = references;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -228,6 +228,30 @@ public class Section {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ThenAction
|
||||||
|
public void redactNotAndReference(@Argument(ArgumentType.TYPE) String type,
|
||||||
|
@Argument(ArgumentType.REFERENCE_TYPE) String referenceType,
|
||||||
|
@Argument(ArgumentType.RULE_NUMBER) int ruleNumber,
|
||||||
|
@Argument(ArgumentType.STRING) String reason) {
|
||||||
|
|
||||||
|
boolean hasRecommendationDictionary = dictionaryTypes.contains(RECOMMENDATION_PREFIX + type);
|
||||||
|
|
||||||
|
Set<Entity> references = entities.stream().filter(entity -> entity.getType().equals(referenceType)).collect(Collectors.toSet());
|
||||||
|
|
||||||
|
entities.forEach(entity -> {
|
||||||
|
if (entity.getType().equals(type) || hasRecommendationDictionary && entity.getType()
|
||||||
|
.equals(RECOMMENDATION_PREFIX + type)) {
|
||||||
|
entity.setRedaction(false);
|
||||||
|
entity.setMatchedRule(ruleNumber);
|
||||||
|
entity.setRedactionReason(reason);
|
||||||
|
entity.setReferences(references);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ThenAction
|
@ThenAction
|
||||||
public void expandToHintAnnotationByRegEx(@Argument(ArgumentType.TYPE) String type,
|
public void expandToHintAnnotationByRegEx(@Argument(ArgumentType.TYPE) String type,
|
||||||
@Argument(ArgumentType.STRING) String pattern,
|
@Argument(ArgumentType.STRING) String pattern,
|
||||||
|
|||||||
@ -149,7 +149,7 @@ public class EntityRedactionService {
|
|||||||
.add(new Entity(entity.getWord(), entity.getType(), entity.isRedaction(), entity.getRedactionReason(), entry
|
.add(new Entity(entity.getWord(), entity.getType(), entity.isRedaction(), entity.getRedactionReason(), entry
|
||||||
.getValue(), entity.getHeadline(), entity.getMatchedRule(), entity.getSectionNumber(), entity
|
.getValue(), entity.getHeadline(), entity.getMatchedRule(), entity.getSectionNumber(), entity
|
||||||
.getLegalBasis(), entity.isDictionaryEntry(), entity.getTextBefore(), entity.getTextAfter(), entity
|
.getLegalBasis(), entity.isDictionaryEntry(), entity.getTextBefore(), entity.getTextAfter(), entity
|
||||||
.getStart(), entity.getEnd(), entity.isDossierDictionaryEntry(), entity.getEngines()));
|
.getStart(), entity.getEnd(), entity.isDossierDictionaryEntry(), entity.getEngines(), entity.getReferences()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entitiesPerPage;
|
return entitiesPerPage;
|
||||||
|
|||||||
@ -159,6 +159,9 @@ public class RedactionLogCreatorService {
|
|||||||
|
|
||||||
private RedactionLogEntry createRedactionLogEntry(Entity entity, String dossierTemplateId) {
|
private RedactionLogEntry createRedactionLogEntry(Entity entity, String dossierTemplateId) {
|
||||||
|
|
||||||
|
Set<String> referenceIds = new HashSet<>();
|
||||||
|
entity.getReferences().forEach(ref -> ref.getPositionSequences().forEach(pos -> referenceIds.add(pos.getId())));
|
||||||
|
|
||||||
return RedactionLogEntry.builder()
|
return RedactionLogEntry.builder()
|
||||||
.color(getColor(entity.getType(), dossierTemplateId, entity.isRedaction()))
|
.color(getColor(entity.getType(), dossierTemplateId, entity.isRedaction()))
|
||||||
.reason(entity.getRedactionReason())
|
.reason(entity.getRedactionReason())
|
||||||
@ -178,6 +181,7 @@ public class RedactionLogCreatorService {
|
|||||||
.endOffset(entity.getEnd())
|
.endOffset(entity.getEnd())
|
||||||
.isDossierDictionaryEntry(entity.isDossierDictionaryEntry())
|
.isDossierDictionaryEntry(entity.isDossierDictionaryEntry())
|
||||||
.engines(entity.getEngines())
|
.engines(entity.getEngines())
|
||||||
|
.reference(referenceIds)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -56,8 +56,8 @@ rule "5: Do not redact Names and Addresses if no redaction Indicator is containe
|
|||||||
when
|
when
|
||||||
Section(matchesType("vertebrate"), matchesType("published_information"))
|
Section(matchesType("vertebrate"), matchesType("published_information"))
|
||||||
then
|
then
|
||||||
section.redactNot("CBI_author", 5, "Vertebrate and Published Information found");
|
section.redactNotAndReference("CBI_author","published_information", 5, "Vertebrate and Published Information found");
|
||||||
section.redactNot("CBI_address", 5, "Vertebrate and Published Information found");
|
section.redactNotAndReference("CBI_address","published_information", 5, "Vertebrate and Published Information found");
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user