Skip to content

Commit

Permalink
fix wrong field name
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitt2 committed Dec 22, 2023
1 parent 200f626 commit 0d310f2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 112 deletions.
108 changes: 10 additions & 98 deletions grobid-core/src/main/java/org/grobid/core/data/Affiliation.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,95 +485,6 @@ public int nbStructures() {
return nbStruct;
}

/*@Deprecated
public String toTEI() {
StringBuilder tei = new StringBuilder();
if (!isNotNull()) {
return null;
} else {
tei.append("<affiliation");
if (key != null)
tei.append(" key=\"").append(key).append("\"");
tei.append(">");
if (departments != null) {
if (departments.size() == 1) {
tei.append("<orgName type=\"department\">").append(TextUtilities.HTMLEncode(departments.get(0))).append("</orgName>");
} else {
int q = 1;
for (String depa : departments) {
tei.append("<orgName type=\"department\" key=\"dep").append(q).append("\">").append(TextUtilities.HTMLEncode(depa)).append("</orgName>");
q++;
}
}
}
if (laboratories != null) {
if (laboratories.size() == 1) {
tei.append("<orgName type=\"laboratory\">").append(TextUtilities.HTMLEncode(laboratories.get(0))).append("</orgName>");
} else {
int q = 1;
for (String labo : laboratories) {
tei.append("<orgName type=\"laboratory\" key=\"lab").append(q).append("\">").append(TextUtilities.HTMLEncode(labo)).append("</orgName>");
q++;
}
}
}
if (institutions != null) {
if (institutions.size() == 1) {
tei.append("<orgName type=\"institution\">").append(TextUtilities.HTMLEncode(institutions.get(0))).append("</orgName>");
} else {
int q = 1;
for (String inst : institutions) {
tei.append("<orgName type=\"institution\" key=\"instit").append(q).append("\">").append(TextUtilities.HTMLEncode(inst)).append("</orgName>");
q++;
}
}
}
if ((getAddressString() != null) |
(getAddrLine() != null) |
(getPostBox() != null) |
(getPostCode() != null) |
(getSettlement() != null) |
(getRegion() != null) |
(getCountry() != null)) {
tei.append("<address>");
if (getAddressString() != null) {
tei.append("<addrLine>").append(TextUtilities.HTMLEncode(getAddressString())).append("</addrLine>");
}
if (getAddrLine() != null) {
tei.append("<addrLine>").append(TextUtilities.HTMLEncode(getAddrLine())).append("</addrLine>");
}
if (getPostBox() != null) {
tei.append("<postBox>").append(TextUtilities.HTMLEncode(getPostBox())).append("</postBox>");
}
if (getPostCode() != null) {
tei.append("<postCode>").append(TextUtilities.HTMLEncode(getPostCode())).append("</postCode>");
}
if (getSettlement() != null) {
tei.append("<settlement>").append(TextUtilities.HTMLEncode(getSettlement())).append("</settlement>");
}
if (getRegion() != null) {
tei.append("<region>").append(TextUtilities.HTMLEncode(getRegion())).append("</region>");
}
if (getCountry() != null) {
Lexicon lexicon = Lexicon.getInstance();
String code = lexicon.getCountryCode(getCountry());
tei.append("<country");
if (code != null)
tei.append(" key=\"").append(code).append("\"");
tei.append(">").append(TextUtilities.HTMLEncode(getCountry())).append("</country>");
}
tei.append("</address>");
}
tei.append("</affiliation>");
}
return tei.toString();
}*/

public static String toTEI(Affiliation aff, int nbTag) {
return toTEI(aff, nbTag, null);
}
Expand Down Expand Up @@ -648,21 +559,22 @@ public static String toTEI(Affiliation aff, int nbTag, GrobidAnalysisConfig conf
}
}

if ((aff.getAddressString() != null) ||
(aff.getAddrLine() != null) ||
(aff.getPostBox() != null) ||
(aff.getPostCode() != null) ||
(aff.getSettlement() != null) ||
(aff.getRegion() != null) ||
(aff.getCountry() != null)) {
if (
aff.getAddrLine() != null ||
aff.getPostBox() != null ||
aff.getPostCode() != null ||
aff.getSettlement() != null ||
aff.getRegion() != null ||
aff.getCountry() != null
) {
TextUtilities.appendN(tei, '\t', nbTag + 2);

tei.append("<address>\n");
if (aff.getAddressString() != null) {
/*if (aff.getAddressString() != null) {
TextUtilities.appendN(tei, '\t', nbTag + 3);
tei.append("<addrLine>" + TextUtilities.HTMLEncode(aff.getAddressString()) +
"</addrLine>\n");
}
}*/
if (aff.getAddrLine() != null) {
TextUtilities.appendN(tei, '\t', nbTag + 3);
tei.append("<addrLine>" + TextUtilities.HTMLEncode(aff.getAddrLine()) +
Expand Down
19 changes: 10 additions & 9 deletions grobid-core/src/main/java/org/grobid/core/data/BiblioItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -3869,21 +3869,22 @@ private void appendAffiliation(
}
}

if ((aff.getAddressString() != null) ||
(aff.getAddrLine() != null) ||
(aff.getPostBox() != null) ||
(aff.getPostCode() != null) ||
(aff.getSettlement() != null) ||
(aff.getRegion() != null) ||
(aff.getCountry() != null)) {
if (
aff.getAddrLine() != null ||
aff.getPostBox() != null ||
aff.getPostCode() != null ||
aff.getSettlement() != null ||
aff.getRegion() != null ||
aff.getCountry() != null
) {
TextUtilities.appendN(tei, '\t', nbTag + 1);

tei.append("<address>\n");
if (aff.getAddressString() != null) {
/*if (aff.getAddressString() != null) {
TextUtilities.appendN(tei, '\t', nbTag + 2);
tei.append("<addrLine>" + TextUtilities.HTMLEncode(aff.getAddressString()) +
"</addrLine>\n");
}
}*/
if (aff.getAddrLine() != null) {
TextUtilities.appendN(tei, '\t', nbTag + 2);
tei.append("<addrLine>" + TextUtilities.HTMLEncode(aff.getAddrLine()) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ protected List<Affiliation> resultExtractionLayoutTokens(String result, List<Lay
affiliation.addLabeledResult(TaggingLabels.AFFILIATION_SETTLEMENT, tokens);

} else if (clusterLabel.equals(TaggingLabels.AFFILIATION_ADDRESSLINE)) {
if (affiliation.getAddressString() != null) {
affiliation.setAddressString(affiliation.getAddressString() + " " + clusterContent);
if (affiliation.getAddrLine() != null) {
affiliation.setAddrLine(affiliation.getAddrLine() + " " + clusterContent);
} else {
affiliation.setAddressString(clusterContent);
affiliation.setAddrLine(clusterContent);
}
affiliation.addLabeledResult(TaggingLabels.AFFILIATION_ADDRESSLINE, tokens);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public static void tearDown(){
GrobidFactory.reset();
}

//@Test
@Test
public void testParser() throws Exception {

String affiliationSequence1 = "Atomic Physics Division, Department of Atomic Physics and Luminescence, " +
"Faculty of Applied Physics and Mathematics, Gdansk University of " +
"Technology, Narutowicza 11/12, 80-233 Gdansk, Poland";
List<Affiliation> res = engine.processAffiliation(affiliationSequence1);
List<Affiliation> res = engine.processAffiliation(affiliationSequence1);
assertEquals(1, res.size());
if (res.size() > 0) {
assertNotNull(res.get(0).getInstitutions());
Expand Down

0 comments on commit 0d310f2

Please sign in to comment.