RED-473: Fixed missing batched produced at annotation
This commit is contained in:
parent
efb05d15a1
commit
bdc231f3c2
@ -94,6 +94,12 @@ public class Section {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void addHintAnnotation(String value, String asType){
|
||||||
|
Set<Entity> found = findEntities(value.trim(), asType, true);
|
||||||
|
entities.addAll(found);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void redactLineAfter(String start, String asType, int ruleNumber, String reason, String legalBasis) {
|
public void redactLineAfter(String start, String asType, int ruleNumber, String reason, String legalBasis) {
|
||||||
|
|
||||||
String[] values = StringUtils.substringsBetween(text, start, "\n");
|
String[] values = StringUtils.substringsBetween(text, start, "\n");
|
||||||
@ -101,7 +107,7 @@ public class Section {
|
|||||||
if (values != null) {
|
if (values != null) {
|
||||||
for (String value : values) {
|
for (String value : values) {
|
||||||
if (StringUtils.isNotBlank(value)) {
|
if (StringUtils.isNotBlank(value)) {
|
||||||
Set<Entity> found = findEntities(value.trim(), asType);
|
Set<Entity> found = findEntities(value.trim(), asType, false);
|
||||||
entities.addAll(found);
|
entities.addAll(found);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,7 +133,7 @@ public class Section {
|
|||||||
if (values != null) {
|
if (values != null) {
|
||||||
for (String value : values) {
|
for (String value : values) {
|
||||||
if (StringUtils.isNotBlank(value)) {
|
if (StringUtils.isNotBlank(value)) {
|
||||||
Set<Entity> found = findEntities(value.trim(), asType);
|
Set<Entity> found = findEntities(value.trim(), asType, false);
|
||||||
entities.addAll(found);
|
entities.addAll(found);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,18 +151,22 @@ public class Section {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Set<Entity> findEntities(String value, String asType) {
|
private Set<Entity> findEntities(String value, String asType, boolean caseinsensitive) {
|
||||||
|
|
||||||
Set<Entity> found = new HashSet<>();
|
Set<Entity> found = new HashSet<>();
|
||||||
|
|
||||||
|
String text = caseinsensitive ? searchText.toLowerCase() : searchText;
|
||||||
|
String searchValue = caseinsensitive ? value.toLowerCase() : value;
|
||||||
|
|
||||||
|
|
||||||
int startIndex;
|
int startIndex;
|
||||||
int stopIndex = 0;
|
int stopIndex = 0;
|
||||||
do {
|
do {
|
||||||
startIndex = searchText.indexOf(value, stopIndex);
|
startIndex = text.indexOf(searchValue, stopIndex);
|
||||||
stopIndex = startIndex + value.length();
|
stopIndex = startIndex + searchValue.length();
|
||||||
|
|
||||||
if (startIndex > -1 && (startIndex == 0 || Character.isWhitespace(searchText.charAt(startIndex - 1)) || isSeparator(
|
if (startIndex > -1 && (startIndex == 0 || Character.isWhitespace(text.charAt(startIndex - 1)) || isSeparator(
|
||||||
searchText.charAt(startIndex - 1))) && (stopIndex == searchText.length() || isSeparator(searchText.charAt(
|
text.charAt(startIndex - 1))) && (stopIndex == text.length() || isSeparator(text.charAt(
|
||||||
stopIndex)))) {
|
stopIndex)))) {
|
||||||
found.add(new Entity(searchText.substring(startIndex, stopIndex),
|
found.add(new Entity(searchText.substring(startIndex, stopIndex),
|
||||||
asType,
|
asType,
|
||||||
|
|||||||
@ -80,7 +80,6 @@ rule "7: Redact contact information if Producer is found"
|
|||||||
when
|
when
|
||||||
Section(text.toLowerCase().contains("producer of the plant protection") || text.toLowerCase().contains("producer of the active substance") || text.contains("Manufacturer of the active substance") || text.contains("Manufacturer:") || text.contains("Producer or producers of the active substance"))
|
Section(text.toLowerCase().contains("producer of the plant protection") || text.toLowerCase().contains("producer of the active substance") || text.contains("Manufacturer of the active substance") || text.contains("Manufacturer:") || text.contains("Producer or producers of the active substance"))
|
||||||
then
|
then
|
||||||
section.redactLineAfter("Contact:", "address", 7, "Producer was found", "Reg (EC) No 1107/2009 Art. 63 (2g)");
|
|
||||||
section.redactLineAfter("Contact:", "address", 7, "Producer was found", "Reg (EC) No 1107/2009 Art. 63 (2g)");
|
section.redactLineAfter("Contact:", "address", 7, "Producer was found", "Reg (EC) No 1107/2009 Art. 63 (2g)");
|
||||||
section.redactLineAfter("Telephone:", "address", 7, "Producer was found", "Reg (EC) No 1107/2009 Art. 63 (2g)");
|
section.redactLineAfter("Telephone:", "address", 7, "Producer was found", "Reg (EC) No 1107/2009 Art. 63 (2g)");
|
||||||
section.redactLineAfter("Phone:", "address", 7, "Producer was found", "Reg (EC) No 1107/2009 Art. 63 (2g)");
|
section.redactLineAfter("Phone:", "address", 7, "Producer was found", "Reg (EC) No 1107/2009 Art. 63 (2g)");
|
||||||
@ -128,4 +127,5 @@ rule "11: Redact sponsor company"
|
|||||||
Section(searchText.toLowerCase().contains("batches produced at"))
|
Section(searchText.toLowerCase().contains("batches produced at"))
|
||||||
then
|
then
|
||||||
section.redactIfPrecededBy("batches produced at", "sponsor", 11, "Redacted because it represents a sponsor company", "Reg (EC) No 1107/2009 Art. 63 (2g)");
|
section.redactIfPrecededBy("batches produced at", "sponsor", 11, "Redacted because it represents a sponsor company", "Reg (EC) No 1107/2009 Art. 63 (2g)");
|
||||||
|
section.addHintAnnotation("batches produced at", "must_redact");
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user