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) {
|
public static ImageType parseImageType(String imageType) {
|
||||||
|
|
||||||
return switch (imageType) {
|
return switch (imageType.toLowerCase()) {
|
||||||
case "LOGO" -> ImageType.LOGO;
|
case "logo" -> ImageType.LOGO;
|
||||||
case "FORMULA" -> ImageType.FORMULA;
|
case "formula" -> ImageType.FORMULA;
|
||||||
case "SIGNATURE" -> ImageType.SIGNATURE;
|
case "signature" -> ImageType.SIGNATURE;
|
||||||
case "OCR" -> ImageType.OCR;
|
case "ocr" -> ImageType.OCR;
|
||||||
default -> ImageType.OTHER;
|
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.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.nodes.SectionNode;
|
||||||
import com.iqser.red.service.redaction.v1.server.layoutparsing.document.graph.textblock.TextBlock;
|
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.AccessLevel;
|
||||||
import lombok.experimental.FieldDefaults;
|
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();
|
List<Boundary> boundaries = entityClusters.stream().filter(cluster -> cluster.size() >= MIN_PART_MATCHES).map(this::toContainingBoundary).distinct().toList();
|
||||||
|
|
||||||
return boundaries.stream()
|
return boundaries.stream()
|
||||||
|
.map(boundary -> removeTrailingSeparator(boundary, textBlock))
|
||||||
.map(boundary -> new EntityRecognitionEntity(textBlock.subSequence(boundary).toString(), boundary.start(), boundary.end(), "CBI_address"))
|
.map(boundary -> new EntityRecognitionEntity(textBlock.subSequence(boundary).toString(), boundary.start(), boundary.end(), "CBI_address"))
|
||||||
.toList();
|
.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) {
|
private static boolean isDuplicate(List<EntityRecognitionEntity> currentCluster, EntityRecognitionEntity entity) {
|
||||||
|
|
||||||
return ALLOW_DUPLICATES || currentCluster.stream().anyMatch(e -> e.getType().equals(entity.getType()));
|
return ALLOW_DUPLICATES || currentCluster.stream().anyMatch(e -> e.getType().equals(entity.getType()));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user