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 2012/03/18 16:44:38 UTC

svn commit: r1302142 - /opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/CrossValidationPartitioner.java

Author: colen
Date: Sun Mar 18 15:44:38 2012
New Revision: 1302142

URL: http://svn.apache.org/viewvc?rev=1302142&view=rev
Log:
OPENNLP-452: Modified to support reseting. Please review.

Modified:
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/CrossValidationPartitioner.java

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/CrossValidationPartitioner.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/CrossValidationPartitioner.java?rev=1302142&r1=1302141&r2=1302142&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/CrossValidationPartitioner.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/eval/CrossValidationPartitioner.java Sun Mar 18 15:44:38 2012
@@ -151,14 +151,22 @@ public class CrossValidationPartitioner<
       
       return sampleStream.read();
     }
-    
+
     /**
-     * Throws <code>UnsupportedOperationException</code>
+     * Resets the training sample. Use this if you need to collect things before
+     * training, for example, to collect induced abbreviations or create a POS
+     * Dictionary.
+     * 
+     * @throws IOException
      */
-    public void reset() {
-      throw new UnsupportedOperationException();
+    public void reset() throws IOException {
+      if (testSampleStream != null || isPoisened) {
+        throw new IllegalStateException();
+      }
+      this.index = 0;
+      this.sampleStream.reset();
     }
-    
+
     public void close() throws IOException {
       sampleStream.close();
       poison();