Skip to content

Commit

Permalink
avoid string concat
Browse files Browse the repository at this point in the history
  • Loading branch information
kermitt2 committed Aug 18, 2020
1 parent 0860f61 commit 99831f7
Showing 1 changed file with 11 additions and 7 deletions.
Expand Up @@ -174,11 +174,14 @@ public String processingHeaderSection(GrobidAnalysisConfig config, Document doc,
}

// language identification
String contentSample = "";
if (resHeader.getTitle() != null)
contentSample += resHeader.getTitle();
if (resHeader.getAbstract() != null)
contentSample += "\n" + resHeader.getAbstract();
StringBuilder contentSample = new StringBuilder();
if (resHeader.getTitle() != null) {
contentSample.append(resHeader.getTitle());
}
if (resHeader.getAbstract() != null) {
contentSample.append("\n");
contentSample.append(resHeader.getAbstract());
}
if (contentSample.length() < 200) {
// we can exploit more textual content to ensure that the language identification will be
// correct
Expand All @@ -196,10 +199,11 @@ public String processingHeaderSection(GrobidAnalysisConfig config, Document doc,
contentBuffer.append(" ");
}
}
contentSample += " " + contentBuffer.toString();
contentSample.append(" ");
contentSample.append(contentBuffer.toString());
}
}
Language langu = languageUtilities.runLanguageId(contentSample);
Language langu = languageUtilities.runLanguageId(contentSample.toString());
if (langu != null) {
String lang = langu.getLang();
doc.setLanguage(lang);
Expand Down

0 comments on commit 99831f7

Please sign in to comment.