Add hint annotation by reg-ex and expand to hint annotation by reg-ex
This commit is contained in:
parent
6d9ed080ce
commit
0f263c69b8
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>platform-dependency</artifactId>
|
<artifactId>platform-dependency</artifactId>
|
||||||
<groupId>com.iqser.red</groupId>
|
<groupId>com.iqser.red</groupId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -140,6 +140,48 @@ public class Section {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void expandToHintAnnotationByRegEx(String type, String pattern, boolean patternCaseInsensitive, int group, String asType) {
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
expanded.addAll(findEntities(entity.getWord() + match, asType, false, false, 0, null, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EntitySearchUtils.addEntitiesWithHigherRank(entities, expanded, dictionary);
|
||||||
|
EntitySearchUtils.removeEntitiesContainedInLarger(entities);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 -> {
|
||||||
|
|||||||
@ -316,9 +316,9 @@ rule "26: Redact On behalf of Syngenta Ltd.:"
|
|||||||
|
|
||||||
// --------------------------------------- other rules -------------------------------------------------------------------
|
// --------------------------------------- other rules -------------------------------------------------------------------
|
||||||
|
|
||||||
rule "27: Redact Purity"
|
rule "27: Purity Hint"
|
||||||
when
|
when
|
||||||
Section(searchText.contains("purity"))
|
Section(searchText.toLowerCase().contains("purity"))
|
||||||
then
|
then
|
||||||
section.redactByRegEx("purity ?:? (([\\d\\.]+)( .{0,4}\\.)? ?%)", true, 1, "purity", 27, "Purity found", "Reg (EC) No 1107/2009 Art. 63 (2a)");
|
section.addHintAnnotationByRegEx("(purity( of)?( ?:)?) [\\d\\.]+( .{0,4}\\.)? ?%", true, 1, "hint_only");
|
||||||
end
|
end
|
||||||
@ -10,7 +10,7 @@
|
|||||||
<Root level="warn">
|
<Root level="warn">
|
||||||
<AppenderRef ref="CONSOLE" />
|
<AppenderRef ref="CONSOLE" />
|
||||||
</Root>
|
</Root>
|
||||||
<Logger name="com.iqser.gin4" level="info" />
|
<Logger name="com.iqser" level="info" />
|
||||||
</Loggers>
|
</Loggers>
|
||||||
|
|
||||||
</Configuration>
|
</Configuration>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user