Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano committed Jan 27, 2025
1 parent 3774737 commit bdfce70
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions grobid-core/src/main/java/org/grobid/core/data/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<TaggingTokenCluster> clusters = clusteror.cluster();
for (TaggingTokenCluster cluster : clusters) {
Expand All @@ -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<Node> refNodes = formatter.markReferencesTEILuceneBased(
cluster.concatTokens(),
Expand All @@ -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");
}
Expand All @@ -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 {
Expand Down

0 comments on commit bdfce70

Please sign in to comment.