Author: rwesten
Date: Wed Feb 27 12:32:43 2013
New Revision: 1450758

URL: http://svn.apache.org/r1450758
Log:
STANBOL-811: Corrected an issue (introduced with the last commit) where the 
SolrCore folder where created/deleted for each call to performCVFold(..) 
instead of once per call to updatePerformanceEstimates(..). The new version is 
more similar to the original one.

Modified:
    
stanbol/trunk/enhancement-engines/topic/engine/src/main/java/org/apache/stanbol/enhancer/engine/topic/TopicClassificationEngine.java

Modified: 
stanbol/trunk/enhancement-engines/topic/engine/src/main/java/org/apache/stanbol/enhancer/engine/topic/TopicClassificationEngine.java
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/enhancement-engines/topic/engine/src/main/java/org/apache/stanbol/enhancer/engine/topic/TopicClassificationEngine.java?rev=1450758&r1=1450757&r2=1450758&view=diff
==============================================================================
--- 
stanbol/trunk/enhancement-engines/topic/engine/src/main/java/org/apache/stanbol/enhancer/engine/topic/TopicClassificationEngine.java
 (original)
+++ 
stanbol/trunk/enhancement-engines/topic/engine/src/main/java/org/apache/stanbol/enhancer/engine/topic/TopicClassificationEngine.java
 Wed Feb 27 12:32:43 2013
@@ -1036,6 +1036,9 @@ public class TopicClassificationEngine e
             throw new ClassifierException("Another evaluation is already 
running");
         }
         int updatedTopics = 0;
+        // NOTE: The folder used to create the SolrServer used for CVFold
+        //       is now created within the #embeddedSolrServerDir
+        File solrServerDir = new File(embeddedSolrServerDir,engineName + 
"-evaluation");
         try {
             evaluationRunning = true;
             int cvFoldCount = 3; // 3-folds CV is hardcoded for now
@@ -1044,11 +1047,11 @@ public class TopicClassificationEngine e
             // We will use the training set quite intensively, ensure that the 
index is packed and its
             // statistics are up to date
             getTrainingSet().optimize();
-
-            // NOTE: The folder used to create the SolrServer used for CVFold
-            //       is now created within the #embeddedSolrServerDir
+            if(!solrServerDir.exists()){
+                FileUtils.forceMkdir(solrServerDir);
+            }
             for (int cvFoldIndex = 0; cvFoldIndex < cvIterationCount; 
cvFoldIndex++) {
-                updatedTopics = performCVFold(cvFoldIndex, cvFoldCount, 
cvIterationCount,
+                updatedTopics = performCVFold(solrServerDir, cvFoldIndex, 
cvFoldCount, cvIterationCount,
                     incremental);
             }
             SolrServer solrServer = getActiveSolrServer();
@@ -1060,12 +1063,14 @@ public class TopicClassificationEngine e
         } catch (SolrServerException e) {
             throw new ClassifierException(e);
         } finally {
+            FileUtils.deleteQuietly(solrServerDir);
             evaluationRunning = false;
         }
         return updatedTopics;
     }
 
-    protected int performCVFold(int cvFoldIndex,
+    protected int performCVFold(File tempFolder,
+                                int cvFoldIndex,
                                 int cvFoldCount,
                                 int cvIterations,
                                 boolean incremental) throws 
ConfigurationException,
@@ -1085,12 +1090,7 @@ public class TopicClassificationEngine e
                 classifier.activate(context, 
getCanonicalConfiguration(engineName + "-evaluation"));
             } else {
                 // non-OSGi runtime, need to do the setup manually
-                File solrServerDir = new File(embeddedSolrServerDir,engineName 
+ "-evaluation");
-                if(solrServerDir.isDirectory()){
-                    FileUtils.forceDelete(solrServerDir);
-                }
-                FileUtils.forceMkdir(solrServerDir);
-                EmbeddedSolrServer evaluationServer = 
EmbeddedSolrHelper.makeEmbeddedSolrServer(solrServerDir,
+                EmbeddedSolrServer evaluationServer = 
EmbeddedSolrHelper.makeEmbeddedSolrServer(tempFolder,
                     "evaluationclassifierserver", "default-topic-model", 
"default-topic-model");
                 
classifier.configure(getCanonicalConfiguration(evaluationServer));
             }


Reply via email to