ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stevenbeth...@apache.org
Subject svn commit: r1490838 - in /ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval: EvaluationOfEventSpans.java EvaluationOfTimeSpans.java
Date Fri, 07 Jun 2013 21:30:36 GMT
Author: stevenbethard
Date: Fri Jun  7 21:30:36 2013
New Revision: 1490838

URL: http://svn.apache.org/r1490838
Log:
Switches ctakes-temporal over to LIBLINEAR instead of LIBSVM

Modified:
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventSpans.java
    ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTimeSpans.java

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventSpans.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventSpans.java?rev=1490838&r1=1490837&r2=1490838&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventSpans.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfEventSpans.java
Fri Jun  7 21:30:36 2013
@@ -34,7 +34,7 @@ import org.cleartk.classifier.Instance;
 import org.cleartk.classifier.feature.transform.InstanceDataWriter;
 import org.cleartk.classifier.feature.transform.InstanceStream;
 import org.cleartk.classifier.jar.JarClassifierBuilder;
-import org.cleartk.classifier.libsvm.LIBSVMStringOutcomeDataWriter;
+import org.cleartk.classifier.liblinear.LIBLINEARStringOutcomeDataWriter;
 import org.cleartk.eval.AnnotationStatistics;
 
 import com.lexicalscope.jewel.cli.CliFactory;
@@ -98,7 +98,7 @@ public class EvaluationOfEventSpans exte
       throws ResourceInitializationException {
     Class<?> dataWriterClass = this.featureSelectionThreshold > 0f
         ? InstanceDataWriter.class
-        : LIBSVMStringOutcomeDataWriter.class;
+        : LIBLINEARStringOutcomeDataWriter.class;
     return EventAnnotator.createDataWriterDescription(
         dataWriterClass,
         directory,
@@ -117,14 +117,14 @@ public class EvaluationOfEventSpans exte
       featureSelection.train(instances);
       featureSelection.save(EventAnnotator.createFeatureSelectionURI(directory));
       // now write in the libsvm format
-      LIBSVMStringOutcomeDataWriter dataWriter = new LIBSVMStringOutcomeDataWriter(directory);
+      LIBLINEARStringOutcomeDataWriter dataWriter = new LIBLINEARStringOutcomeDataWriter(directory);
       for (Instance<String> instance : instances) {
         dataWriter.write(featureSelection.transform(instance));
       }
       dataWriter.finish();
     }
 
-    JarClassifierBuilder.trainAndPackage(directory, "-c", "10000");
+    JarClassifierBuilder.trainAndPackage(directory, "-c", "0.05");
   }
 
   @Override

Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTimeSpans.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTimeSpans.java?rev=1490838&r1=1490837&r2=1490838&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTimeSpans.java
(original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/eval/EvaluationOfTimeSpans.java
Fri Jun  7 21:30:36 2013
@@ -36,7 +36,7 @@ import org.cleartk.classifier.jar.Defaul
 import org.cleartk.classifier.jar.DirectoryDataWriterFactory;
 import org.cleartk.classifier.jar.GenericJarClassifierFactory;
 import org.cleartk.classifier.jar.JarClassifierBuilder;
-import org.cleartk.classifier.libsvm.LIBSVMStringOutcomeDataWriter;
+import org.cleartk.classifier.liblinear.LIBLINEARStringOutcomeDataWriter;
 import org.cleartk.eval.AnnotationStatistics;
 import org.uimafit.factory.AnalysisEngineFactory;
 
@@ -58,6 +58,9 @@ public class EvaluationOfTimeSpans exten
     List<Class<? extends CleartkAnnotator<String>>> annotatorClasses =
Lists.newArrayList();
     annotatorClasses.add(TimeAnnotator.class);
     annotatorClasses.add(ConstituencyBasedTimeAnnotator.class);
+    Map<Class<? extends CleartkAnnotator<String>>, String[]> annotatorTrainingArguments
= Maps.newHashMap();
+    annotatorTrainingArguments.put(TimeAnnotator.class, new String[]{"-c", "0.1"});
+    annotatorTrainingArguments.put(ConstituencyBasedTimeAnnotator.class, new String[]{"-c",
"1"});
     
     // run one evaluation per annotator class
     final Map<Class<?>, AnnotationStatistics<?>> annotatorStats = Maps.newHashMap();
@@ -68,7 +71,8 @@ public class EvaluationOfTimeSpans exten
           options.getKnowtatorXMLDirectory(),
           options.getXMIDirectory(),
           options.getTreebankDirectory(),
-          annotatorClass);
+          annotatorClass,
+          annotatorTrainingArguments.get(annotatorClass));
       evaluation.prepareXMIsFor(patientSets);
       String name = String.format("%s.errors", annotatorClass.getSimpleName());
       evaluation.setLogging(Level.FINE, new File("target/eval", name));
@@ -95,15 +99,19 @@ public class EvaluationOfTimeSpans exten
 
   private Class<? extends CleartkAnnotator<String>> annotatorClass;
 
+  private String[] trainingArguments;
+
   public EvaluationOfTimeSpans(
       File baseDirectory,
       File rawTextDirectory,
       File knowtatorXMLDirectory,
       File xmiDirectory,
       File treebankDirectory,
-      Class<? extends CleartkAnnotator<String>> annotatorClass) {
+      Class<? extends CleartkAnnotator<String>> annotatorClass,
+      String[] trainingArguments) {
     super(baseDirectory, rawTextDirectory, knowtatorXMLDirectory, xmiDirectory, treebankDirectory,
TimeMention.class);
     this.annotatorClass = annotatorClass;
+    this.trainingArguments = trainingArguments;
   }
 
   @Override
@@ -114,14 +122,14 @@ public class EvaluationOfTimeSpans exten
         CleartkAnnotator.PARAM_IS_TRAINING,
         true,
         DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
-        LIBSVMStringOutcomeDataWriter.class,
+        LIBLINEARStringOutcomeDataWriter.class,
         DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
         this.getModelDirectory(directory));
   }
 
   @Override
   protected void trainAndPackage(File directory) throws Exception {
-    JarClassifierBuilder.trainAndPackage(this.getModelDirectory(directory), "-c", "10000");
+    JarClassifierBuilder.trainAndPackage(this.getModelDirectory(directory), this.trainingArguments);
   }
 
   @Override



Mime
View raw message