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/19 11:11:05 UTC

Re: svn commit: r1159447 - in /incubator/opennlp/trunk/opennlp-tools/src: main/java/opennlp/tools/chunker/ main/java/opennlp/tools/cmdline/chunker/ main/java/opennlp/tools/cmdline/namefind/ main/java/opennlp/tools/cmdline/postag/ main/java/opennlp/tools/cm...

On 8/19/11 1:40 AM, colen@apache.org wrote:
> ==============================================================================
> --- 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 Thu Aug 18 23:40:24 2011
> @@ -19,7 +19,6 @@
>   package opennlp.tools.util.eval;
>
>   import java.io.IOException;
> -import java.util.LinkedList;
>   import java.util.List;
>
>   import opennlp.tools.util.ObjectStream;
> @@ -32,7 +31,15 @@ import opennlp.tools.util.ObjectStream;
>    */
>   public abstract class Evaluator<T>  {
>
> -  private List<EvaluationSampleListener<T>>  listeners = new LinkedList<EvaluationSampleListener<T>>();
> +  private List<EvaluationSampleListener<T>>  listeners;
> +
> +  public Evaluator() {
> +    this.listeners = null;
> +  }
> +
> +  public Evaluator(List<EvaluationSampleListener<T>>  listeners) {
> +    this.listeners = listeners;
> +  }

I still believe that the case where you just have one 
EvaluationSampleListener object that
should be hooked up is the most frequent use case, and its very rare 
that people want to
hookup multiple.

To make that easy, I suggest that we add a constructor which just takes 
one listener.

The declaration of the generic list here enforces that a caller needs to 
pass in a list
which has a EvaluationSampelListener<T> as generic parameter.
But an user might just have a list of this type List<MySampleListener> where
MySampleListener implements EvaluationSampleListener<POSSample>.

For this reason "input" collections are usually declared like this:
List<? extends EvaluationSampleListener<T>>

Now its possible to pass in Lists which define a sub-type of 
EvaluationSampleListener
as their generic parameter.

We also need to make a copy of the list, to encapsulate the state of 
Evaluator.

And I now more and more feel like that we picked a bad name with 
EvaluationSampleListener,
sounds a little confusing. Maybe EvaluationMonitor would be better, any 
opinions?

Jörn