RED-6009 - Document Tree Structure
* fix parse imageType * fix getMatchedRule * remove trailing separator from Ai Entities
This commit is contained in:
parent
fe818b65d0
commit
8ec3c32a85
@ -92,11 +92,11 @@ public class PropertiesMapper {
|
||||
|
||||
public static ImageType parseImageType(String imageType) {
|
||||
|
||||
return switch (imageType) {
|
||||
case "LOGO" -> ImageType.LOGO;
|
||||
case "FORMULA" -> ImageType.FORMULA;
|
||||
case "SIGNATURE" -> ImageType.SIGNATURE;
|
||||
case "OCR" -> ImageType.OCR;
|
||||
return switch (imageType.toLowerCase()) {
|
||||
case "logo" -> ImageType.LOGO;
|
||||
case "formula" -> ImageType.FORMULA;
|
||||
case "signature" -> ImageType.SIGNATURE;
|
||||
case "ocr" -> ImageType.OCR;
|
||||
default -> ImageType.OTHER;
|
||||
};
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import com.iqser.red.service.redaction.v1.server.layoutparsing.document.graph.Bo
|
||||
import com.iqser.red.service.redaction.v1.server.layoutparsing.document.graph.nodes.DocumentGraph;
|
||||
import com.iqser.red.service.redaction.v1.server.layoutparsing.document.graph.nodes.SectionNode;
|
||||
import com.iqser.red.service.redaction.v1.server.layoutparsing.document.graph.textblock.TextBlock;
|
||||
import com.iqser.red.service.redaction.v1.server.redaction.utils.SeparatorUtils;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
@ -90,11 +91,21 @@ public class NerEntitiesAdapter {
|
||||
List<Boundary> boundaries = entityClusters.stream().filter(cluster -> cluster.size() >= MIN_PART_MATCHES).map(this::toContainingBoundary).distinct().toList();
|
||||
|
||||
return boundaries.stream()
|
||||
.map(boundary -> removeTrailingSeparator(boundary, textBlock))
|
||||
.map(boundary -> new EntityRecognitionEntity(textBlock.subSequence(boundary).toString(), boundary.start(), boundary.end(), "CBI_address"))
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
private Boundary removeTrailingSeparator(Boundary boundary, TextBlock textBlock) {
|
||||
|
||||
if (SeparatorUtils.isSeparator(textBlock.charAt(boundary.end() - 1))) {
|
||||
return new Boundary(boundary.start(), boundary.end());
|
||||
}
|
||||
return boundary;
|
||||
}
|
||||
|
||||
|
||||
private static boolean isDuplicate(List<EntityRecognitionEntity> currentCluster, EntityRecognitionEntity entity) {
|
||||
|
||||
return ALLOW_DUPLICATES || currentCluster.stream().anyMatch(e -> e.getType().equals(entity.getType()));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user