Skip to content

Commit

Permalink
keep xml for late serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitt2 committed Aug 7, 2023
1 parent 4b88b9c commit a627fbe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 3 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 @@ -37,6 +37,9 @@ public class Funding {

private List<LayoutToken> layoutTokens = new ArrayList<>();

private Date start = null;
private Date end = null;

public Funder getFunder() {
return this.funder;
}
Expand Down
6 changes: 4 additions & 2 deletions grobid-core/src/main/java/org/grobid/core/engines/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple;

import nu.xom.Element;

import org.grobid.core.data.Affiliation;
import org.grobid.core.data.BibDataSet;
import org.grobid.core.data.BiblioItem;
Expand Down Expand Up @@ -1087,13 +1089,13 @@ public String processFundingAcknowledgement(String text, GrobidAnalysisConfig co
StringBuilder result = new StringBuilder();

try {
Pair<String, Triple<List<Funding>,List<Person>,List<Affiliation>>> localResult =
Pair<Element, Triple<List<Funding>,List<Person>,List<Affiliation>>> localResult =
parsers.getFundingAcknowledgementParser().processing(text, config);

if (localResult == null || localResult.getLeft() == null)
result.append(text);
else
result.append(localResult.getLeft());
result.append(localResult.getLeft().toXML());

} catch (final Exception exp) {
throw new GrobidException("An exception occured while running Grobid funding-acknowledgement model.", exp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected FundingAcknowledgementParser() {
super(GrobidModels.FUNDING_ACKNOWLEDGEMENT);
}

private Pair<String, Triple<List<Funding>,List<Person>,List<Affiliation>>>
private Pair<Element, Triple<List<Funding>,List<Person>,List<Affiliation>>>
processing(List<LayoutToken> tokenizationFunding, GrobidAnalysisConfig config) {
if (tokenizationFunding == null || tokenizationFunding.size() == 0)
return null;
Expand All @@ -82,7 +82,7 @@ protected FundingAcknowledgementParser() {
* For convenience, a processing method taking a raw string as input.
* Tokenization is done with the default Grobid analyzer triggered by the identified language.
**/
public Pair<String, Triple<List<Funding>,List<Person>,List<Affiliation>>> processing(String text,
public Pair<Element, Triple<List<Funding>,List<Person>,List<Affiliation>>> processing(String text,
GrobidAnalysisConfig config) {
text = UnicodeUtil.normaliseText(text);
List<LayoutToken> tokenizationFunding = GrobidAnalyzer.getInstance().tokenizeWithLayoutToken(text);
Expand All @@ -103,7 +103,7 @@ public Pair<String, Triple<List<Funding>,List<Person>,List<Affiliation>>> proces
* extracted normalized entities. These entities are referenced by the inline
* annotations with the usual @target attribute pointing to xml:id.
*/
private Pair<String, Triple<List<Funding>,List<Person>,List<Affiliation>>>
private Pair<Element, Triple<List<Funding>,List<Person>,List<Affiliation>>>
getExtractionResult(List<LayoutToken> tokenizations, String result) {
List<Funding> fundings = new ArrayList<>();
List<Person> persons = new ArrayList<>();
Expand Down Expand Up @@ -338,7 +338,7 @@ public Pair<String, Triple<List<Funding>,List<Person>,List<Affiliation>>> proces

Triple<List<Funding>,List<Person>,List<Affiliation>> entities = Triple.of(fundings, persons, affiliations);

return Pair.of(curParagraph.toXML(), entities);
return Pair.of(curParagraph, entities);
}

/**
Expand Down

0 comments on commit a627fbe

Please sign in to comment.