You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by co...@apache.org on 2011/08/23 19:06:54 UTC
svn commit: r1160806 -
/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java
Author: colen
Date: Tue Aug 23 17:06:54 2011
New Revision: 1160806
URL: http://svn.apache.org/viewvc?rev=1160806&view=rev
Log:
OPENNLP-226 Now Evaluator has only one constructor that receives a variable length param.
Modified:
incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java
Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java?rev=1160806&r1=1160805&r2=1160806&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java Tue Aug 23 17:06:54 2011
@@ -19,9 +19,6 @@
package opennlp.tools.util.eval;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
import opennlp.tools.util.ObjectStream;
@@ -33,22 +30,10 @@ import opennlp.tools.util.ObjectStream;
*/
public abstract class Evaluator<T> {
- private List<EvaluationMonitor<T>> listeners;
-
- public Evaluator() {
- this.listeners = null;
- }
-
- public Evaluator(List<? extends EvaluationMonitor<T>> listeners) {
- if(listeners != null) {
- this.listeners = new LinkedList<EvaluationMonitor<T>>(listeners);
- }
- }
+ private EvaluationMonitor<T>[] listeners;
public Evaluator(EvaluationMonitor<T>... listeners) {
- if(listeners != null) {
- this.listeners = Arrays.asList(listeners);
- }
+ this.listeners = listeners;
}
/**
Re: svn commit: r1160806 - /incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java
Posted by Jörn Kottmann <ko...@gmail.com>.
On 8/24/11 12:33 AM, william.colen@gmail.com wrote:
> I see. I will have to do the same in each CV tool because there we
> also keep a copy of the monitors array.
I also saw that, maybe we should just move that up in an
AbstractCrossValidator, all the cross validators need a little
refactoring anyway, would be nice to move more up. But that can wait.
Jörn
Re: svn commit: r1160806 - /incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java
Posted by "william.colen@gmail.com" <wi...@gmail.com>.
On Tue, Aug 23, 2011 at 7:13 PM, Jörn Kottmann <ko...@gmail.com> wrote:
> On 8/23/11 7:06 PM, colen@apache.org wrote:
>
>> public Evaluator(EvaluationMonitor<T>**... listeners) {
>> - if(listeners != null) {
>> - this.listeners = Arrays.asList(listeners);
>> - }
>> + this.listeners = listeners;
>> }
>>
>
> We again need to make a copy here, because an array would just be
> passed by its reference and can be modified afterwards by the caller.
> Because of that the Evaluator object cannot encapsulate it.
>
> Maybe just keep the old list, and copy it into it. Usually you would
> do an array copy, but that is not possible without a warning here ...
>
> Jörn
>
I see. I will have to do the same in each CV tool because there we also keep
a copy of the monitors array.
Re: svn commit: r1160806 - /incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java
Posted by Jörn Kottmann <ko...@gmail.com>.
On 8/23/11 7:06 PM, colen@apache.org wrote:
> public Evaluator(EvaluationMonitor<T>... listeners) {
> - if(listeners != null) {
> - this.listeners = Arrays.asList(listeners);
> - }
> + this.listeners = listeners;
> }
We again need to make a copy here, because an array would just be
passed by its reference and can be modified afterwards by the caller.
Because of that the Evaluator object cannot encapsulate it.
Maybe just keep the old list, and copy it into it. Usually you would
do an array copy, but that is not possible without a warning here ...
Jörn