Skip to content

Commit

Permalink
fix coordinates merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano committed May 5, 2024
1 parent 6336512 commit 9199170
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,10 @@ private static Nodes mergeSentencesFallingOnAnnotations(Nodes sentences, List<Pa
destCoordinates = destination.getAttribute("coords");
String coordinates = destCoordinates.getValue();
boundingBoxes = Arrays.stream(coordinates.split(";"))
.filter(StringUtils::isNotBlank)
.map(BoundingBox::fromString)
.collect(Collectors.toList());
destination.removeAttribute(destCoordinates);
}

for (int i = 1; i < toMerge.size(); i++) {
Expand All @@ -288,16 +290,16 @@ private static Nodes mergeSentencesFallingOnAnnotations(Nodes sentences, List<Pa

// Merge coordinates
if (needToMergeCoordinates) {
Attribute coords = destination.getAttribute("coords");
Attribute coords = ((Element) sentenceToMerge).getAttribute("coords");
String coordinates = coords.getValue();
boundingBoxes.addAll(Arrays.stream(coordinates.split(";"))
.filter(StringUtils::isNotBlank)
.map(BoundingBox::fromString)
.toList());

List<BoundingBox> mergedBoundingBoxes = mergeBoxes(boundingBoxes);
String coordsAsString = String.join(";", mergedBoundingBoxes.stream().map(BoundingBox::toString).toList());
Attribute newCoords = new Attribute("coords", coordsAsString);
destination.removeAttribute(coords);
destination.addAttribute(newCoords);
}

Expand Down

0 comments on commit 9199170

Please sign in to comment.