Do not return redacted=true for vertebrates in RedactionLog, return isHint=true and redacted=false

This commit is contained in:
deiflaender 2020-07-22 13:56:40 +02:00
parent 41c61dd214
commit 6a9df397eb
4 changed files with 17 additions and 23 deletions

View File

@ -13,6 +13,7 @@ public class RedactionLogEntry {
private String value; private String value;
private String reason; private String reason;
private boolean redacted; private boolean redacted;
private boolean isHint;
private String section; private String section;
private float[] color; private float[] color;
private List<Rectangle> positions = new ArrayList<>(); private List<Rectangle> positions = new ArrayList<>();

View File

@ -49,15 +49,6 @@ public class Section {
}); });
} }
public void highlightAll(String type){
entities.forEach(entity -> {
if(entity.getType().equals(type)){
entity.setRedaction(true);
}
});
}
public void redactLineAfter(String start, String asType, int ruleNumber, String reason){ public void redactLineAfter(String start, String asType, int ruleNumber, String reason){
String value = StringUtils.substringBetween(text, start, "\n"); String value = StringUtils.substringBetween(text, start, "\n");

View File

@ -121,7 +121,7 @@ public class AnnotationHighlightService {
annotationPosition.setUpperRightY(posYEnd + height); annotationPosition.setUpperRightY(posYEnd + height);
highlight.setRectangle(annotationPosition); highlight.setRectangle(annotationPosition);
if (!flatRedaction) { if (!flatRedaction && !isHint(entity)) {
highlight.setAnnotationName(entityPositionSequence.getId().toString()); highlight.setAnnotationName(entityPositionSequence.getId().toString());
highlight.setTitlePopup(entityPositionSequence.getId().toString()); highlight.setTitlePopup(entityPositionSequence.getId().toString());
highlight.setContents("\nRule " + entity.getMatchedRule() + " matched\n\n" + entity.getRedactionReason() + "\n\n" + "In Section : \"" + entity.getHeadline() + "\""); highlight.setContents("\nRule " + entity.getMatchedRule() + " matched\n\n" + entity.getRedactionReason() + "\n\n" + "In Section : \"" + entity.getHeadline() + "\"");
@ -150,6 +150,7 @@ public class AnnotationHighlightService {
redactionLogEntry.setType(entity.getType()); redactionLogEntry.setType(entity.getType());
redactionLogEntry.setRedacted(entity.isRedaction()); redactionLogEntry.setRedacted(entity.isRedaction());
redactionLogEntry.setSection(entity.getHeadline()); redactionLogEntry.setSection(entity.getHeadline());
redactionLogEntry.setHint(isHint(entity));
classifiedDoc.getRedactionLogEntities().add(redactionLogEntry); classifiedDoc.getRedactionLogEntities().add(redactionLogEntry);
} }
@ -173,15 +174,15 @@ public class AnnotationHighlightService {
if (!entity.isRedaction()) { if (!entity.isRedaction()) {
return false; return false;
} }
if(entity.getType().equalsIgnoreCase("VERTEBRATE") || entity.getType().equalsIgnoreCase("NO_REDACTION_INDICATOR") ){ if(isHint(entity)){
// TODO in RED-161. return false;
return true;
} }
return dictionaryService.getDictionary().keySet().contains(entity.getType()); return true;
} }
private float[] getColor(Entity entity) { private float[] getColor(Entity entity) {
if (!entity.isRedaction()) {
if (!entity.isRedaction() && !isHint(entity)) {
return new float[]{0.627f, 0.627f, 0.627f}; return new float[]{0.627f, 0.627f, 0.627f};
} }
@ -192,6 +193,15 @@ public class AnnotationHighlightService {
return dictionaryService.getEntryColors().get(entity.getType()); return dictionaryService.getEntryColors().get(entity.getType());
} }
private boolean isHint(Entity entity){
// TODO in RED-161.
if(entity.getType().equalsIgnoreCase("vertebrate") || entity.getType().equalsIgnoreCase("no_redaction_indicator")){
return true;
}
return false;
}
private void visualizeTextBlock(TextBlock textBlock, PDPageContentStream contentStream) throws IOException { private void visualizeTextBlock(TextBlock textBlock, PDPageContentStream contentStream) throws IOException {
contentStream.setStrokingColor(Color.LIGHT_GRAY); contentStream.setStrokingColor(Color.LIGHT_GRAY);

View File

@ -4,14 +4,6 @@ import com.iqser.red.service.redaction.v1.server.redaction.model.Section
global Section section global Section section
rule "0: Highlight Indicators"
when
eval(section.getEntities().isEmpty()==false);
then
section.highlightAll("vertebrate");
section.highlightAll("no_redaction_indicator");
end
rule "1: Redacted because Section contains Vertebrate" rule "1: Redacted because Section contains Vertebrate"
when when