RED-9139: move document to its own module, add TableOfContents and TableOfContentsItem
* update LayoutEngine package
This commit is contained in:
parent
6ae777c802
commit
f8a97f306e
@ -92,10 +92,7 @@ public class DocumentStructureWrapper implements Serializable {
|
|||||||
|
|
||||||
public Stream<EntryData> streamAllEntries() {
|
public Stream<EntryData> streamAllEntries() {
|
||||||
|
|
||||||
return Stream.concat(Stream.of(documentStructure.getRoot()),
|
return flatten(documentStructure.getRoot());
|
||||||
documentStructure.getRoot().getChildrenList()
|
|
||||||
.stream())
|
|
||||||
.flatMap(DocumentStructureWrapper::flatten);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.iqser.red.service.redaction.v1.server.data.DocumentData;
|
import com.iqser.red.service.redaction.v1.server.data.DocumentData;
|
||||||
import com.iqser.red.service.redaction.v1.server.data.DocumentPageProto.AllDocumentPages;
|
import com.iqser.red.service.redaction.v1.server.data.DocumentPageProto.AllDocumentPages;
|
||||||
@ -59,10 +58,6 @@ public class DocumentDataMapper {
|
|||||||
|
|
||||||
AllDocumentPositionData allDocumentPositionData = AllDocumentPositionData.newBuilder().addAllDocumentPositionData(atomicPositionBlockData).build();
|
AllDocumentPositionData allDocumentPositionData = AllDocumentPositionData.newBuilder().addAllDocumentPositionData(atomicPositionBlockData).build();
|
||||||
|
|
||||||
Set<Long> nonEmptyTextBlocks = documentTextData.stream()
|
|
||||||
.mapToLong(DocumentTextData::getId).boxed()
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
List<DocumentPage> documentPageData = document.getPages()
|
List<DocumentPage> documentPageData = document.getPages()
|
||||||
.stream()
|
.stream()
|
||||||
.map(DocumentDataMapper::toPageData)
|
.map(DocumentDataMapper::toPageData)
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public class PropertiesMapper {
|
|||||||
public static Map<String, String> buildImageProperties(Image image) {
|
public static Map<String, String> buildImageProperties(Image image) {
|
||||||
|
|
||||||
Map<String, String> properties = new HashMap<>();
|
Map<String, String> properties = new HashMap<>();
|
||||||
properties.put(DocumentStructureWrapper.ImageProperties.IMAGE_TYPE, image.getImageType().toString());
|
properties.put(DocumentStructureWrapper.ImageProperties.IMAGE_TYPE, image.getImageType().name());
|
||||||
properties.put(DocumentStructureWrapper.ImageProperties.TRANSPARENT, String.valueOf(image.isTransparent()));
|
properties.put(DocumentStructureWrapper.ImageProperties.TRANSPARENT, String.valueOf(image.isTransparent()));
|
||||||
properties.put(DocumentStructureWrapper.ImageProperties.POSITION, toString(image.getPosition()));
|
properties.put(DocumentStructureWrapper.ImageProperties.POSITION, toString(image.getPosition()));
|
||||||
properties.put(DocumentStructureWrapper.ImageProperties.ID, image.getId());
|
properties.put(DocumentStructureWrapper.ImageProperties.ID, image.getId());
|
||||||
@ -118,13 +118,11 @@ public class PropertiesMapper {
|
|||||||
|
|
||||||
private static ImageType parseImageType(String imageType) {
|
private static ImageType parseImageType(String imageType) {
|
||||||
|
|
||||||
return switch (imageType) {
|
try {
|
||||||
case "LOGO" -> ImageType.LOGO;
|
return ImageType.valueOf(imageType.toUpperCase(Locale.ROOT));
|
||||||
case "FORMULA" -> ImageType.FORMULA;
|
} catch (IllegalArgumentException e) {
|
||||||
case "SIGNATURE" -> ImageType.SIGNATURE;
|
return ImageType.OTHER;
|
||||||
case "OCR" -> ImageType.OCR;
|
}
|
||||||
default -> ImageType.OTHER;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -111,7 +111,7 @@ public class Image extends AbstractSemanticNode implements IEntity {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
return getTreeId() + ": " + getValue() + " " + position;
|
return getTreeId() + ": " + getValue() + " [%.2f,%.2f,%.2f,%.2f]".formatted(position.getX(), position.getY(), position.getWidth(), position.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -169,4 +169,11 @@ public class Image extends AbstractSemanticNode implements IEntity {
|
|||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLeaf() {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,4 +37,11 @@ public class TableOfContents extends AbstractSemanticNode {
|
|||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
return getTreeId() + ": " + NodeType.TABLE_OF_CONTENTS_ITEM + ": " + getTextBlock().buildSummary();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,4 +47,11 @@ public class TableOfContentsItem extends AbstractSemanticNode {
|
|||||||
return leafTextBlock;
|
return leafTextBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
return getTreeId() + ": " + NodeType.TABLE_OF_CONTENTS_ITEM + ": " + leafTextBlock.buildSummary();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user