67 lines
2.2 KiB
Plaintext
67 lines
2.2 KiB
Plaintext
package drools
|
|
|
|
import static java.lang.String.format;
|
|
|
|
import java.util.List;
|
|
import java.util.LinkedList;
|
|
import java.util.HashSet;
|
|
|
|
import com.iqser.red.service.redaction.v1.server.redaction.model.*;
|
|
import com.iqser.red.service.redaction.v1.model.Engine;
|
|
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.type.DictionaryEntry;
|
|
import com.iqser.red.service.redaction.v1.server.redaction.utils.EntitySearchUtils;
|
|
import java.util.Set;
|
|
|
|
global Dictionary dictionary
|
|
|
|
query "getEntities"
|
|
$result: Entity()
|
|
end
|
|
|
|
// --------------------------------------- AI rules -------------------------------------------------------------------
|
|
rule "0: find entities from entry dictionary"
|
|
salience 100
|
|
when
|
|
$section: Section()
|
|
$paragraph: Paragraph(sectionNumber == $section.sectionNumber)
|
|
$entityPositionSequence: EntityPositionSequence() from EntitySearchUtils.findEntityPositionSequences("M. Must", $paragraph.getSearchTextToTextPosition())
|
|
then
|
|
List<EntityPositionSequence> eps = new LinkedList<>();
|
|
eps.add($entityPositionSequence);
|
|
Set<Engine> engineSet = new HashSet<>();
|
|
engineSet.add(Engine.DICTIONARY);
|
|
Set<Entity> empty = new HashSet<>();
|
|
insert(new Entity("CBI_author",
|
|
"custom",
|
|
true,
|
|
format("Found in Dictionary: %s", "custom"),
|
|
eps,
|
|
$section.getHeadline(),
|
|
0,
|
|
$section.getSectionNumber(),
|
|
$paragraph.getParagraphNumber(),
|
|
"",
|
|
true,
|
|
"",
|
|
"",
|
|
-1,
|
|
-1,
|
|
false,
|
|
engineSet,
|
|
empty,
|
|
EntityType.ENTITY
|
|
));
|
|
end
|
|
|
|
/*
|
|
rule "44: Don't redact Author if contained in paragraph with published information"
|
|
when
|
|
$section: Section()
|
|
$paragraph: Paragraph($section.sectionNumber == sectionNumber)
|
|
|
|
$authorEntity: Entity(type == "CBI_author", paragraphNumber == $paragraph.getParagraphNumber())
|
|
$publishedEntity: Entity(type == "published_information", paragraphNumber == $paragraph.getParagraphNumber())
|
|
then
|
|
$authorEntity.setRedaction(false);
|
|
end
|
|
*/ |