Skip to content

Commit 8f50e32

Browse files
committed
Use StringBuilder to concatenate in BasicTextAnnotationBuilder
1 parent bce700c commit 8f50e32

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core-utilities/src/main/java/edu/illinois/cs/cogcomp/annotation/BasicTextAnnotationBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ public static TextAnnotation createTextAnnotationFromListofListofTokens(List<Lis
7979
public static TextAnnotation createTextAnnotationFromTokens(String corpusId, String textId,
8080
List<String[]> tokenizedSentences) {
8181
Tokenization tokenization = tokenizeTextSpan(tokenizedSentences);
82-
String text = "";
82+
StringBuilder text = new StringBuilder();
8383
for (String[] sentenceTokens : tokenizedSentences)
84-
text += StringUtils.join(sentenceTokens, ' ') + System.lineSeparator();
84+
text.append(StringUtils.join(sentenceTokens, ' '))
85+
.append(System.lineSeparator());
8586

86-
return new TextAnnotation(corpusId, textId, text, tokenization.getCharacterOffsets(),
87+
return new TextAnnotation(corpusId, textId, text.toString(), tokenization.getCharacterOffsets(),
8788
tokenization.getTokens(), tokenization.getSentenceEndTokenIndexes());
8889
}
8990

0 commit comments

Comments
 (0)