Skip to content

Commit

Permalink
add crfpp-templates file
Browse files Browse the repository at this point in the history
  • Loading branch information
tantikristanti committed Aug 7, 2019
1 parent fc63217 commit a93f2c2
Show file tree
Hide file tree
Showing 16 changed files with 1,498 additions and 162 deletions.
206 changes: 206 additions & 0 deletions grobid-core/src/main/java/org/grobid/core/data/Acknowledgment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
package org.grobid.core.data;

import org.grobid.core.utilities.TextUtilities;

public class Acknowledgment {
private String affiliation = null;
private String educationalInstitution = null;
private String fundingAgency = null;
private String grantName = null;
private String grantNumber = null;
private String individual = null;
private String otherInstitution = null;
private String projectName = null;
private String researchInstitution = null;

public String getAffiliation() {
return affiliation;
}

public void setAffiliation(String affiliation) {
this.affiliation = affiliation;
}

public String getEducationalInstitution() {
return educationalInstitution;
}

public void setEducationalInstitution(String educationalInstitution) {
this.educationalInstitution = educationalInstitution;
}

public String getFundingAgency() {
return fundingAgency;
}

public void setFundingAgency(String fundingAgency) {
this.fundingAgency = fundingAgency;
}

public String getGrantName() {
return grantName;
}

public void setGrantName(String grantName) {
this.grantName = grantName;
}

public String getGrantNumber() {
return grantNumber;
}

public void setGrantNumber(String grantNumber) {
this.grantNumber = grantNumber;
}

public String getIndividual() {
return individual;
}

public void setIndividual(String individual) {
this.individual = individual;
}

public String getOtherInstitution() {
return otherInstitution;
}

public void setOtherInstitution(String otherInstitution) {
this.otherInstitution = otherInstitution;
}

public String getProjectName() {
return projectName;
}

public void setProjectName(String projectName) {
this.projectName = projectName;
}

public String getResearchInstitution() {
return researchInstitution;
}

public void setResearchInstitution(String researchInstitution) {
this.researchInstitution = researchInstitution;
}

public boolean isNotNull() {
if ((affiliation == null) &
(educationalInstitution == null) &
(fundingAgency == null) &
(grantName == null) &
(grantNumber == null) &
(individual == null) &
(otherInstitution == null) &
(projectName == null) &
(researchInstitution == null))
return false;
else
return true;
}

public void clean() {
if (affiliation != null) {
affiliation = TextUtilities.cleanField(affiliation, true);
if (affiliation.length() < 2)
affiliation = null;
}

if (educationalInstitution != null) {
educationalInstitution = TextUtilities.cleanField(educationalInstitution, true);
if (educationalInstitution.length() < 2)
educationalInstitution = null;
}

if (fundingAgency != null) {
fundingAgency = TextUtilities.cleanField(fundingAgency, true);
if (fundingAgency.length() < 2)
fundingAgency = null;
}

if (grantName != null) {
grantName = TextUtilities.cleanField(grantName, true);
if (grantName.length() < 2)
grantName = null;
}

if (grantNumber != null) {
grantNumber = TextUtilities.cleanField(grantNumber, true);
if (grantNumber.length() < 2)
grantNumber = null;
}

if (individual != null) {
individual = TextUtilities.cleanField(individual, true);
if (individual.length() < 2)
individual = null;
}

if (otherInstitution != null) {
otherInstitution = TextUtilities.cleanField(otherInstitution, true);
if (otherInstitution.length() < 2)
otherInstitution = null;
}

if (projectName != null) {
projectName = TextUtilities.cleanField(projectName, true);
if (projectName.length() < 2)
projectName = null;
}

if (researchInstitution != null) {
researchInstitution = TextUtilities.cleanField(researchInstitution, true);
if (researchInstitution.length() < 2)
researchInstitution = null;
}
}

public String toTEI(){
StringBuilder tei = new StringBuilder();
if (!isNotNull()) {
return null;
} else {
tei.append("<acknowledgment");

if (affiliation != null) {
tei.append("<affiliation>").append(TextUtilities.HTMLEncode(affiliation)).append("</affiliation>");
}

if (educationalInstitution != null) {
tei.append("<educationalInstitution>").append(TextUtilities.HTMLEncode(educationalInstitution)).append("</educationalInstitution>");
}

if (fundingAgency != null) {
tei.append("<fundingAgency>").append(TextUtilities.HTMLEncode(fundingAgency)).append("</fundingAgency>");
}

if (grantName != null) {
tei.append("<grantName>").append(TextUtilities.HTMLEncode(grantName)).append("</grantName>");
}

if (grantNumber != null) {
tei.append("<grantNumber>").append(TextUtilities.HTMLEncode(grantNumber)).append("</grantNumber>");
}

if (individual != null) {
tei.append("<individual>").append(TextUtilities.HTMLEncode(individual)).append("</individual>");
}

if (otherInstitution != null) {
tei.append("<otherInstitution>").append(TextUtilities.HTMLEncode(otherInstitution)).append("</otherInstitution>");
}

if (projectName != null) {
tei.append("<projectName>").append(TextUtilities.HTMLEncode(projectName)).append("</projectName>");
}

if (researchInstitution != null) {
tei.append("<researchInstitution>").append(TextUtilities.HTMLEncode(researchInstitution)).append("</researchInstitution>");
}
tei.append("</acknowledgment>");
}
return tei.toString();
}
}

Loading

0 comments on commit a93f2c2

Please sign in to comment.