Skip to content

Commit

Permalink
filter out fp crossref results
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitt2 committed Aug 13, 2023
1 parent a28e2a1 commit 2d1e9ed
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
13 changes: 13 additions & 0 deletions grobid-core/src/main/java/org/grobid/core/data/Funding.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ public boolean isValid() {
return false;
}

public boolean isNonEmptyFunding() {
if (grantNumber != null ||
grantName != null ||
projectFullName != null ||
projectAbbreviatedName != null ||
programFullName != null ||
programAbbreviatedName != null ||
url != null)
return true;
else
return false;
}

public String toString() {
StringBuilder builder = new StringBuilder();
if (funder != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ public StringBuilder toTEIHeader(BiblioItem biblio,
// inject funding ref in the funder entries
String referenceString = "";
for(Funding funderFunding : entry.getValue()) {
referenceString += " #" + funderFunding.getIdentifier();
if (funderFunding.isNonEmptyFunding())
referenceString += " #" + funderFunding.getIdentifier();
}

if (funderPiece != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,33 @@ private void toTEI(Document doc,

List<String> annexStatements = new ArrayList<>();

// acknowledgement is in the back
StringBuilder acknowledgmentStmt = getSectionAsTEI("acknowledgement", "\t\t\t", doc, SegmentationLabels.ACKNOWLEDGEMENT,
teiFormatter, resCitations, config);

if (acknowledgmentStmt.length() > 0) {
MutablePair<Element, MutableTriple<List<Funding>,List<Person>,List<Affiliation>>> localResult =
parsers.getFundingAcknowledgementParser().processingXmlFragment(acknowledgmentStmt.toString(), config);

if (localResult != null && localResult.getLeft() != null) {
String local_tei = localResult.getLeft().toXML();
local_tei = local_tei.replace(" xmlns=\"http://www.tei-c.org/ns/1.0\"", "");
//tei.append(local_tei);
annexStatements.add(local_tei);
}
else {
//tei.append(acknowledgmentStmt);
annexStatements.add(acknowledgmentStmt.toString());
}

if (localResult != null && localResult.getRight() != null && localResult.getRight().getLeft() != null) {
List<Funding> localFundings = localResult.getRight().getLeft();
if (localFundings.size()>0) {
fundings.addAll(localFundings);
}
}
}

// funding in header
StringBuilder fundingStmt = new StringBuilder();
if (StringUtils.isNotBlank(resHeader.getFunding())) {
Expand Down Expand Up @@ -2529,33 +2556,6 @@ private void toTEI(Document doc,
annexStatements.add(fundingStmt.toString());
}

if (localResult != null && localResult.getRight() != null && localResult.getRight().getLeft() != null) {
List<Funding> localFundings = localResult.getRight().getLeft();
if (localFundings.size()>0) {
fundings.addAll(localFundings);
}
}
}

// acknowledgement is in the back
StringBuilder acknowledgmentStmt = getSectionAsTEI("acknowledgement", "\t\t\t", doc, SegmentationLabels.ACKNOWLEDGEMENT,
teiFormatter, resCitations, config);

if (acknowledgmentStmt.length() > 0) {
MutablePair<Element, MutableTriple<List<Funding>,List<Person>,List<Affiliation>>> localResult =
parsers.getFundingAcknowledgementParser().processingXmlFragment(acknowledgmentStmt.toString(), config);

if (localResult != null && localResult.getLeft() != null) {
String local_tei = localResult.getLeft().toXML();
local_tei = local_tei.replace(" xmlns=\"http://www.tei-c.org/ns/1.0\"", "");
//tei.append(local_tei);
annexStatements.add(local_tei);
}
else {
//tei.append(acknowledgmentStmt);
annexStatements.add(acknowledgmentStmt.toString());
}

if (localResult != null && localResult.getRight() != null && localResult.getRight().getLeft() != null) {
List<Funding> localFundings = localResult.getRight().getLeft();
if (localFundings.size()>0) {
Expand All @@ -2577,7 +2577,8 @@ private void toTEI(Document doc,

tei.append("\t\t\t<listOrg type=\"funding\">\n");
for(Funding funding : fundings) {
tei.append(funding.toTEI(3));
if (funding.isNonEmptyFunding())
tei.append(funding.toTEI(3));
}
tei.append("\t\t\t</listOrg>");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,10 @@ public void onSuccess(List<Funder> res) {
for(Funder oneRes : res) {
/*
Glutton integrates its own post-validation, so we can skip post-validation in GROBID when it is used as
consolidation service.
consolidation service. However, with CrossRef, post-validation is mandatory to control false positives.
*/
results.add(oneRes);
if (oneRes.getFullName() != null && oneRes.getFullName().toLowerCase().equals(funder.getFullName().toLowerCase()))
results.add(oneRes);
}
}
}
Expand Down

0 comments on commit 2d1e9ed

Please sign in to comment.