From bdfce7074c7040f067a7b6379f5dead25c59dee9 Mon Sep 17 00:00:00 2001 From: Luca Foppiano Date: Mon, 27 Jan 2025 21:20:06 +0900 Subject: [PATCH] simplify --- .../src/main/java/org/grobid/core/data/Table.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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 08fea642fa..d273fb02f1 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 @@ -180,7 +180,7 @@ public String toTEI(GrobidAnalysisConfig config, Document doc, TEIFormatter form } if (StringUtils.isNotEmpty(labeledNote) ) { - Element p = null; + Element p = teiElement("p"); TaggingTokenClusteror clusteror = new TaggingTokenClusteror(GrobidModels.FULLTEXT, labeledNote, noteLayoutTokens); List clusters = clusteror.cluster(); for (TaggingTokenCluster cluster : clusters) { @@ -197,10 +197,6 @@ public String toTEI(GrobidAnalysisConfig config, Document doc, TEIFormatter form //String clusterContent = LayoutTokensUtil.normalizeText(cluster.concatTokens()); String clusterContent = LayoutTokensUtil.normalizeDehyphenizeText(cluster.concatTokens()); if (clusterLabel.equals(TaggingLabels.CITATION_MARKER)) { - if (p == null) { - LOGGER.warn("Problem when serializing TEI fragment for table note, there is a reference at the beginning of the sentence. "); - p = teiElement("p"); - } try { List refNodes = formatter.markReferencesTEILuceneBased( cluster.concatTokens(), @@ -217,9 +213,7 @@ public String toTEI(GrobidAnalysisConfig config, Document doc, TEIFormatter form LOGGER.warn("Problem when serializing TEI fragment for table note", e); } } else { - if (p == null) { - p = teiElement("p"); - } else if (isNewParagraph(clusterLabel, p)) { + if (p.getChildCount() > 0 && isNewParagraph(clusterLabel, p)) { noteNode.appendChild(p); p = teiElement("p"); } @@ -231,7 +225,7 @@ public String toTEI(GrobidAnalysisConfig config, Document doc, TEIFormatter form formatter.segmentIntoSentences(noteNode, this.noteLayoutTokens, config, doc.getLanguage(), doc.getPDFAnnotations()); } } - if (p != null && p.getChildCount() > 0) { + if (p.getChildCount() > 0) { noteNode.appendChild(p); } } else {