From 3bc567e24cdbcefa1c6f1cfffea63ac490d7cdc5 Mon Sep 17 00:00:00 2001 From: Luca Foppiano Date: Sun, 19 Jan 2025 19:50:29 +0900 Subject: [PATCH] cosmetics --- .../src/main/java/org/grobid/core/data/Figure.java | 10 +++++----- .../src/main/java/org/grobid/core/data/Table.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grobid-core/src/main/java/org/grobid/core/data/Figure.java b/grobid-core/src/main/java/org/grobid/core/data/Figure.java index ef43f2072a..c9ddfa2664 100644 --- a/grobid-core/src/main/java/org/grobid/core/data/Figure.java +++ b/grobid-core/src/main/java/org/grobid/core/data/Figure.java @@ -276,7 +276,7 @@ public List getCoordinates() { List theBoxes = null; // non graphic elements - if (getLayoutTokens() != null && getLayoutTokens().size() > 0) { + if (CollectionUtils.isNotEmpty(getLayoutTokens())) { //theBoxes = BoundingBoxCalculator.calculate(getLayoutTokens()); BoundingBox oneBox = BoundingBoxCalculator.calculateOneBox(layoutTokens, true); List result = new ArrayList(); @@ -291,7 +291,7 @@ public List getCoordinates() { // here we bound all figure graphics in one single box (given that we can have hundred graphics // in a single figure) BoundingBox theGraphicsBox = null; - if ((graphicObjects != null) && (graphicObjects.size() > 0)) { + if (CollectionUtils.isNotEmpty(graphicObjects)) { for (GraphicObject graphicObject : graphicObjects) { if (theGraphicsBox == null) { theGraphicsBox = graphicObject.getBoundingBox(); @@ -307,8 +307,8 @@ public List getCoordinates() { theBoxes.add(theGraphicsBox); } - List result = new ArrayList(); - if (theBoxes != null && theBoxes.size() > 0) { + List result = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(theBoxes)) { BoundingBox oneBox = BoundingBoxCalculator.calculateOneBox(layoutTokens, true); List mergedBox = VectorGraphicBoxCalculator.mergeBoxes(theBoxes); result.addAll(mergedBox); @@ -436,7 +436,7 @@ public String toTEI(GrobidAnalysisConfig config, Document doc, TEIFormatter form // LayoutTokensUtil.normalizeText(caption.toString())); } - if (desc != null && config.isWithSentenceSegmentation()) { + if (config.isWithSentenceSegmentation()) { formatter.segmentIntoSentences(desc, this.captionLayoutTokens, config, doc.getLanguage(), doc.getPDFAnnotations()); // we need a sentence segmentation of the figure caption, for that we need to introduce diff --git a/grobid-core/src/main/java/org/grobid/core/data/Table.java b/grobid-core/src/main/java/org/grobid/core/data/Table.java index 2806fa212d..e6a14a253d 100644 --- a/grobid-core/src/main/java/org/grobid/core/data/Table.java +++ b/grobid-core/src/main/java/org/grobid/core/data/Table.java @@ -147,7 +147,7 @@ public String toTEI(GrobidAnalysisConfig config, Document doc, TEIFormatter form desc.appendChild(textNode(clusterContent)); } - if (desc != null && config.isWithSentenceSegmentation()) { + if (config.isWithSentenceSegmentation()) { formatter.segmentIntoSentences(desc, this.captionLayoutTokens, config, doc.getLanguage(), doc.getPDFAnnotations()); // we need a sentence segmentation of the table caption, for that we need to introduce