You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by ma...@apache.org on 2012/10/30 03:41:10 UTC

svn commit: r1403608 - in /incubator/ctakes/trunk/ctakes-assertion: ./ src/main/java/org/apache/ctakes/assertion/eval/ src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/

Author: mattcoarr
Date: Tue Oct 30 02:41:10 2012
New Revision: 1403608

URL: http://svn.apache.org/viewvc?rev=1403608&view=rev
Log:
fixed some compilation issues that with the assertion evaluation code that were causing problems with some "maven compile" builds

Added:
    incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/XMIReader.java
    incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionComponents.java
Modified:
    incubator/ctakes/trunk/ctakes-assertion/pom.xml
    incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionCleartkAnalysisEngine.java
    incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/TrainAssertionModel.java

Modified: incubator/ctakes/trunk/ctakes-assertion/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-assertion/pom.xml?rev=1403608&r1=1403607&r2=1403608&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-assertion/pom.xml (original)
+++ incubator/ctakes/trunk/ctakes-assertion/pom.xml Tue Oct 30 02:41:10 2012
@@ -70,6 +70,14 @@
 			<artifactId>cleartk-test-util</artifactId>
 		</dependency>
 		<dependency>
+			<groupId>org.cleartk</groupId>
+			<artifactId>cleartk-eval</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.cleartk</groupId>
+			<artifactId>cleartk-examples</artifactId>
+		</dependency>
+				<dependency>
 			<groupId>args4j</groupId>
 			<artifactId>args4j</artifactId>
 		</dependency>
@@ -105,6 +113,11 @@
 		</dependency>
 
 		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+		</dependency>
+
+				<dependency>
 			<groupId>log4j</groupId>
 			<artifactId>log4j</artifactId>
 		</dependency>

Added: incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/XMIReader.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/XMIReader.java?rev=1403608&view=auto
==============================================================================
--- incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/XMIReader.java (added)
+++ incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/XMIReader.java Tue Oct 30 02:41:10 2012
@@ -0,0 +1,67 @@
+package org.apache.ctakes.assertion.eval;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.uima.UimaContext;
+import org.apache.uima.cas.impl.XmiCasDeserializer;
+import org.apache.uima.collection.CollectionException;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.util.Progress;
+import org.apache.uima.util.ProgressImpl;
+import org.uimafit.component.JCasCollectionReader_ImplBase;
+import org.uimafit.descriptor.ConfigurationParameter;
+import org.xml.sax.SAXException;
+
+/**
+ * UIMA CollectionReader that reads in CASes from XMI files.
+ */
+public class XMIReader extends JCasCollectionReader_ImplBase {
+
+  public static final String PARAM_FILES = "files";
+
+  @ConfigurationParameter(
+      name = PARAM_FILES,
+      mandatory = true,
+      description = "The XMI files to be loaded")
+  private List<File> files;
+
+  private Iterator<File> filesIter;
+
+  private int completed;
+
+  @Override
+  public void initialize(UimaContext context) throws ResourceInitializationException {
+    super.initialize(context);
+    this.filesIter = files.iterator();
+    this.completed = 0;
+  }
+
+  @Override
+  public Progress[] getProgress() {
+    return new Progress[] { new ProgressImpl(this.completed, this.files.size(), Progress.ENTITIES) };
+  }
+
+  @Override
+  public boolean hasNext() throws IOException, CollectionException {
+    return this.filesIter.hasNext();
+  }
+
+  @Override
+  public void getNext(JCas jCas) throws IOException, CollectionException {
+    FileInputStream inputStream = new FileInputStream(this.filesIter.next());
+    try {
+      XmiCasDeserializer.deserialize(new BufferedInputStream(inputStream), jCas.getCas());
+    } catch (SAXException e) {
+      throw new CollectionException(e);
+    }
+    inputStream.close();
+    this.completed += 1;
+  }
+
+}
\ No newline at end of file

Modified: incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionCleartkAnalysisEngine.java?rev=1403608&r1=1403607&r2=1403608&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionCleartkAnalysisEngine.java (original)
+++ incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionCleartkAnalysisEngine.java Tue Oct 30 02:41:10 2012
@@ -41,12 +41,12 @@ import org.uimafit.factory.AnalysisEngin
 import org.uimafit.factory.ConfigurationParameterFactory;
 import org.uimafit.util.JCasUtil;
 
-import edu.mayo.bmi.uima.core.type.structured.DocumentID;
-import edu.mayo.bmi.uima.core.type.syntax.BaseToken;
-import edu.mayo.bmi.uima.core.type.textsem.EntityMention;
-import edu.mayo.bmi.uima.core.type.textsem.EventMention;
-import edu.mayo.bmi.uima.core.type.textsem.IdentifiedAnnotation;
-import edu.mayo.bmi.uima.core.type.textspan.Sentence;
+import org.apache.ctakes.typesystem.type.structured.DocumentID;
+import org.apache.ctakes.typesystem.type.syntax.BaseToken;
+import org.apache.ctakes.typesystem.type.textsem.EntityMention;
+import org.apache.ctakes.typesystem.type.textsem.EventMention;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
 
 public class AssertionCleartkAnalysisEngine extends
     CleartkAnnotator<String>

Added: incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionComponents.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionComponents.java?rev=1403608&view=auto
==============================================================================
--- incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionComponents.java (added)
+++ incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/AssertionComponents.java Tue Oct 30 02:41:10 2012
@@ -0,0 +1,44 @@
+package org.apache.ctakes.assertion.medfacts.cleartk;
+
+/* 
+ * Copyright (c) 2010, Regents of the University of Colorado 
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
+ * Neither the name of the University of Colorado at Boulder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.uimafit.factory.TypeSystemDescriptionFactory;
+
+/**
+ * <br>
+ * Copyright (c) 2010, Regents of the University of Colorado <br>
+ * All rights reserved.
+ * <p>
+ */
+
+public class AssertionComponents {
+
+  public static TypeSystemDescription TYPE_SYSTEM_DESCRIPTION = TypeSystemDescriptionFactory
+      .createTypeSystemDescription("org.apache.ctakes.assertion.types.TypeSystem");
+  public static TypeSystemDescription CTAKES_CTS_TYPE_SYSTEM_DESCRIPTION = TypeSystemDescriptionFactory
+      .createTypeSystemDescription("org.apache.ctakes.typesystem.types.TypeSystem");
+
+}

Modified: incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/TrainAssertionModel.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/TrainAssertionModel.java?rev=1403608&r1=1403607&r2=1403608&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/TrainAssertionModel.java (original)
+++ incubator/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/TrainAssertionModel.java Tue Oct 30 02:41:10 2012
@@ -36,12 +36,12 @@ import org.uimafit.factory.CollectionRea
 import org.uimafit.factory.ConfigurationParameterFactory;
 import org.uimafit.pipeline.SimplePipeline;
 import org.uimafit.testing.util.HideOutput;
-import org.junit.Test;
+//import org.junit.Test;
 import org.apache.ctakes.assertion.medfacts.AssertionAnalysisEngine;
-import edu.mayo.bmi.uima.core.type.syntax.BaseToken;
+import org.apache.ctakes.typesystem.type.syntax.BaseToken;
 //import edu.mayo.bmi.uima.core.type.textsem.EntityMention;
-import edu.mayo.bmi.uima.core.type.textsem.IdentifiedAnnotation;
-import edu.mayo.bmi.uima.core.type.textspan.Sentence;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.ctakes.typesystem.type.textspan.Sentence;
 import org.cleartk.classifier.jar.DefaultDataWriterFactory;
 import org.cleartk.examples.pos.ExamplePOSPlainTextWriter;
 
@@ -88,7 +88,7 @@ public class TrainAssertionModel {
 	
 	protected String modelOutputDirectory = "/work/medfacts/cleartk/data/train.model";
 
-  @Test
+  //@Test
   public void testMaxent() throws Exception {
     
     String trainingDataDirectory = "/work/medfacts/cleartk/data/train";