You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@opennlp.apache.org by Jörn Kottmann <ko...@gmail.com> on 2011/08/24 00:13:41 UTC

Re: svn commit: r1160806 - /incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/Evaluator.java

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

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.