purity
This commit is contained in:
parent
db5baee889
commit
7f7de6ce2a
@ -140,7 +140,7 @@ public class Section {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void dismissByRegEx(String type, String pattern, boolean patternCaseInsensitive, int group) {
|
public void expandToHintAnnotationByRegEx(String type, String pattern, boolean patternCaseInsensitive, int group, String asType) {
|
||||||
|
|
||||||
Pattern compiledPattern = Patterns.getCompiledPattern(pattern, patternCaseInsensitive);
|
Pattern compiledPattern = Patterns.getCompiledPattern(pattern, patternCaseInsensitive);
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ public class Section {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
String match = matcher.group(group);
|
String match = matcher.group(group);
|
||||||
if (StringUtils.isNotBlank(match)) {
|
if (StringUtils.isNotBlank(match)) {
|
||||||
expanded.addAll(findEntities(entity.getWord() + match, type, false, entity.isRedaction(), 0, null, null));
|
expanded.addAll(findEntities(entity.getWord() + match, asType, false, false, 0, null, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,6 +166,24 @@ public class Section {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void addHintAnnotationByRegEx(String pattern, boolean patternCaseInsensitive, int group, String asType) {
|
||||||
|
|
||||||
|
Pattern compiledPattern = Patterns.getCompiledPattern(pattern, patternCaseInsensitive);
|
||||||
|
|
||||||
|
Matcher matcher = compiledPattern.matcher(searchText);
|
||||||
|
|
||||||
|
while (matcher.find()) {
|
||||||
|
String match = matcher.group(group);
|
||||||
|
if (StringUtils.isNotBlank(match)) {
|
||||||
|
Set<Entity> found = findEntities(match.trim(), asType, false, false, 0, null, null);
|
||||||
|
EntitySearchUtils.addEntitiesWithHigherRank(entities, found, dictionary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void redactIfPrecededBy(String prefix, String type, int ruleNumber, String reason, String legalBasis) {
|
public void redactIfPrecededBy(String prefix, String type, int ruleNumber, String reason, String legalBasis) {
|
||||||
|
|
||||||
entities.forEach(entity -> {
|
entities.forEach(entity -> {
|
||||||
|
|||||||
@ -119,6 +119,44 @@ public class EntityRedactionServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGenitiveDismissal() throws IOException {
|
||||||
|
|
||||||
|
ClassPathResource pdfFileResource = new ClassPathResource("files/Metolachlor/S-Metolachlor_RAR_01_Volume_1_2018-09-06.pdf");
|
||||||
|
when(dictionaryClient.getVersion(TEST_RULESET_ID)).thenReturn(DICTIONARY_VERSION.incrementAndGet());
|
||||||
|
DictionaryResponse dictionaryResponse = DictionaryResponse.builder()
|
||||||
|
.entries(new ArrayList<>(ResourceLoader.load("dictionaries/CBI_author.txt")))
|
||||||
|
.build();
|
||||||
|
when(dictionaryClient.getDictionaryForType(AUTHOR_CODE, TEST_RULESET_ID)).thenReturn(dictionaryResponse);
|
||||||
|
DictionaryResponse addressResponse = DictionaryResponse.builder()
|
||||||
|
.entries(new ArrayList<>(ResourceLoader.load("dictionaries/CBI_address.txt")))
|
||||||
|
.build();
|
||||||
|
when(dictionaryClient.getDictionaryForType(ADDRESS_CODE, TEST_RULESET_ID)).thenReturn(addressResponse);
|
||||||
|
DictionaryResponse sponsorResponse = DictionaryResponse.builder()
|
||||||
|
.entries(Collections.emptyList())
|
||||||
|
.build();
|
||||||
|
when(dictionaryClient.getDictionaryForType(SPONSOR_CODE, TEST_RULESET_ID)).thenReturn(sponsorResponse);
|
||||||
|
try (PDDocument pdDocument = PDDocument.load(pdfFileResource.getInputStream())) {
|
||||||
|
Document classifiedDoc = pdfSegmentationService.parseDocument(pdDocument);
|
||||||
|
entityRedactionService.processDocument(classifiedDoc, TEST_RULESET_ID, null);
|
||||||
|
assertThat(classifiedDoc.getEntities()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.noneMatch(entry -> entry.getValue().stream().anyMatch(e -> e.getMatchedRule() == 9))).isTrue();
|
||||||
|
}
|
||||||
|
pdfFileResource = new ClassPathResource("files/Compounds/27 A8637C - EU AIR3 - MCP Section 1 - Identity of " +
|
||||||
|
"the plant protection product.pdf");
|
||||||
|
try (PDDocument pdDocument = PDDocument.load(pdfFileResource.getInputStream())) {
|
||||||
|
Document classifiedDoc = pdfSegmentationService.parseDocument(pdDocument);
|
||||||
|
entityRedactionService.processDocument(classifiedDoc, TEST_RULESET_ID, null);
|
||||||
|
assertThat(classifiedDoc.getEntities()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.noneMatch(entry -> entry.getValue().stream().anyMatch(e -> e.getMatchedRule() == 9))).isTrue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTableRedaction() throws IOException {
|
public void testTableRedaction() throws IOException {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user