[
https://issues.apache.org/jira/browse/OPENNLP-363?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13146543#comment-13146543
]
Joern Kottmann commented on OPENNLP-363:
----------------------------------------
Reviewed your patch.
These I would leave as they are, because it makes the code harder to read, the
code
is not executed often and the performance improvement would not be noticeable
at all.
---
a/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADNameSampleStream.java
+++
b/opennlp-tools/src/main/java/opennlp/tools/formats/ad/ADNameSampleStream.java
@@ -244,9 +244,7 @@ public class ADNameSampleStream implements
ObjectStream<NameSample> {
if (leafTag.contains("<sam->")) {
String[] lexemes = leaf.getLexeme().split("_");
if(lexemes.length > 1) {
- for (int i = 0; i < lexemes.length - 1; i++) {
- sentence.add(lexemes[i]);
- }
+ sentence.addAll(Arrays.asList(lexemes).subList(0, lexemes.length
- 1));
}
leftContractionPart = lexemes[lexemes.length - 1];
return;
---
a/opennlp-tools/src/main/java/opennlp/tools/cmdline/DetailedFMeasureListener.java
+++
b/opennlp-tools/src/main/java/opennlp/tools/cmdline/DetailedFMeasureListener.java
@@ -120,9 +120,8 @@ public abstract class DetailedFMeasureListener<T> implements
StringBuilder ret = new StringBuilder();
int tp = generalStats.getTruePositives();
int found = generalStats.getFalsePositives() + tp;
- ret.append("Evaluated " + samples + " samples with "
- + generalStats.getTarget() + " entities; found: " + found
- + " entities; correct: " + tp + ".\n");
+ ret.append("Evaluated ").append(samples).append(" samples with
").append(generalStats.getTarget()).
+ append(" entities; found: ").append(found).append(" entities; correct:
").append(tp).append(".\n");
All other changes are fine, but we need to do a little performance testing. Do
you know if the system array copy is always faster?
Or only when the arrays have a certain size?
> performance-issues: manual array or collection copy, appending strings,
> string creation, extra .toString()
> -----------------------------------------------------------------------------------------------------------
>
> Key: OPENNLP-363
> URL: https://issues.apache.org/jira/browse/OPENNLP-363
> Project: OpenNLP
> Issue Type: Improvement
> Affects Versions: tools-1.5.3-incubating, maxent-3.0.3-incubating
> Reporter: Aliaksandr Autayeu
> Priority: Minor
> Labels: patch
> Attachments:
> 0003-performance-issues-manual-array-or-collection-copy-a.patch
>
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> There are multiple performance nuisances: manual array or collection copy,
> appending strings, string creation, extra .toString() calls.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira