Skip to content

Commit

Permalink
Merge pull request #1076 from kermitt2/bugfix/paragraph-coords
Browse files Browse the repository at this point in the history
Fix missing coordinates in paragraphs continuation
  • Loading branch information
kermitt2 authored Jan 21, 2024
2 parents cbc77d5 + 0d7913d commit e14ce33
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,13 @@ public StringBuilder toTEITextPiece(StringBuilder buffer,

curDiv.appendChild(curParagraph);
curParagraphTokens = new ArrayList<>();
} else {
if (config.isGenerateTeiCoordinates("p")) {
String coords = LayoutTokensUtil.getCoordsString(clusterTokens);
if (curParagraph.getAttribute("coords") != null && !curParagraph.getAttributeValue("coords").contains(coords)) {
curParagraph.addAttribute(new Attribute("coords", curParagraph.getAttributeValue("coords") + ";" + coords));
}
}
}
curParagraph.appendChild(clusterContent);
curParagraphTokens.addAll(clusterTokens);
Expand Down
16 changes: 15 additions & 1 deletion grobid-service/src/main/resources/web/grobid/grobid.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var grobid = (function($) {

var block = 0;

var elementCoords = ['s', 'biblStruct', 'persName', 'figure', 'formula', 'head', 'note', 'title', 'affiliation'];
var elementCoords = ['p', 's', 'biblStruct', 'persName', 'figure', 'formula', 'head', 'note', 'title', 'affiliation'];

function defineBaseURL(ext) {
var baseUrl = null;
Expand Down Expand Up @@ -239,10 +239,15 @@ var grobid = (function($) {

function ShowRequest1(formData, jqForm, options) {
var addCoordinates = false;
var segmentSentences = false;
for(var formd in formData) {
if (formData[formd].name == 'teiCoordinates') {
addCoordinates = true;
}
if (formData[formd].name == 'segmentSentences') {
segmentSentences = true;
}

}
if (addCoordinates) {
for (var i in elementCoords) {
Expand All @@ -252,6 +257,15 @@ var grobid = (function($) {
"type": "checkbox",
"required": false
}
if (segmentSentences === false) {
if (elementCoords[i] === "s") {
continue;
}
} else {
if (elementCoords[i] === "p") {
continue;
}
}
additionalFormData["value"] = elementCoords[i]
formData.push(additionalFormData)
}
Expand Down

0 comments on commit e14ce33

Please sign in to comment.