Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing coordinates in paragraphs continuation #1076

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading