uima-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r992213 - in /uima/sandbox/trunk/SnowballAnnotator/src: main/java/org/apache/uima/ main/java/org/apache/uima/annotator/ test/java/org/apache/uima/annotator/
Date Fri, 03 Sep 2010 05:34:33 GMT
Author: tommaso
Date: Fri Sep  3 05:34:32 2010
New Revision: 992213

URL: http://svn.apache.org/viewvc?rev=992213&view=rev
Log:
[UIMA-1861] - applying Marshall's patch plus headers in generated TS generated files and testReconfigure()
in SnowballAnnotatorTest

Added:
    uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/SentenceAnnotation.java
    uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/SentenceAnnotation_Type.java
    uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/TokenAnnotation.java
    uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/TokenAnnotation_Type.java
Modified:
    uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/annotator/SnowballAnnotator.java
    uima/sandbox/trunk/SnowballAnnotator/src/test/java/org/apache/uima/annotator/SnowballAnnotatorTest.java

Added: uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/SentenceAnnotation.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/SentenceAnnotation.java?rev=992213&view=auto
==============================================================================
--- uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/SentenceAnnotation.java
(added)
+++ uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/SentenceAnnotation.java
Fri Sep  3 05:34:32 2010
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* First created by JCasGen Thu Sep 02 14:47:15 EDT 2010 */
+package org.apache.uima;
+
+import org.apache.uima.jcas.JCas; 
+import org.apache.uima.jcas.JCasRegistry;
+import org.apache.uima.jcas.cas.TOP_Type;
+
+import org.apache.uima.jcas.tcas.Annotation;
+
+
+/** sentence annotation
+ * Updated by JCasGen Thu Sep 02 14:47:15 EDT 2010
+ * XML source: D:/mavenAlign/sandbox-trunk-data/SnowballAnnotator/desc/SnowballAnnotator.xml
+ * @generated */
+public class SentenceAnnotation extends Annotation {
+  /** @generated
+   * @ordered 
+   */
+  public final static int typeIndexID = JCasRegistry.register(SentenceAnnotation.class);
+  /** @generated
+   * @ordered 
+   */
+  public final static int type = typeIndexID;
+  /** @generated  */
+  public              int getTypeIndexID() {return typeIndexID;}
+ 
+  /** Never called.  Disable default constructor
+   * @generated */
+  protected SentenceAnnotation() {}
+    
+  /** Internal - constructor used by generator 
+   * @generated */
+  public SentenceAnnotation(int addr, TOP_Type type) {
+    super(addr, type);
+    readObject();
+  }
+  
+  /** @generated */
+  public SentenceAnnotation(JCas jcas) {
+    super(jcas);
+    readObject();   
+  } 
+
+  /** @generated */  
+  public SentenceAnnotation(JCas jcas, int begin, int end) {
+    super(jcas);
+    setBegin(begin);
+    setEnd(end);
+    readObject();
+  }   
+
+  /** <!-- begin-user-doc -->
+    * Write your own initialization here
+    * <!-- end-user-doc -->
+  @generated modifiable */
+  private void readObject() {}
+     
+}
+
+    
\ No newline at end of file

Added: uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/SentenceAnnotation_Type.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/SentenceAnnotation_Type.java?rev=992213&view=auto
==============================================================================
--- uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/SentenceAnnotation_Type.java
(added)
+++ uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/SentenceAnnotation_Type.java
Fri Sep  3 05:34:32 2010
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/* First created by JCasGen Thu Sep 02 14:47:15 EDT 2010 */
+package org.apache.uima;
+
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.JCasRegistry;
+import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.impl.FSGenerator;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.Type;
+import org.apache.uima.jcas.tcas.Annotation_Type;
+
+/** sentence annotation
+ * Updated by JCasGen Thu Sep 02 14:47:15 EDT 2010
+ * @generated */
+public class SentenceAnnotation_Type extends Annotation_Type {
+  /** @generated */
+  protected FSGenerator getFSGenerator() {return fsGenerator;}
+  /** @generated */
+  private final FSGenerator fsGenerator = 
+    new FSGenerator() {
+      public FeatureStructure createFS(int addr, CASImpl cas) {
+  			 if (SentenceAnnotation_Type.this.useExistingInstance) {
+  			   // Return eq fs instance if already created
+  		     FeatureStructure fs = SentenceAnnotation_Type.this.jcas.getJfsFromCaddr(addr);
+  		     if (null == fs) {
+  		       fs = new SentenceAnnotation(addr, SentenceAnnotation_Type.this);
+  			   SentenceAnnotation_Type.this.jcas.putJfsFromCaddr(addr, fs);
+  			   return fs;
+  		     }
+  		     return fs;
+        } else return new SentenceAnnotation(addr, SentenceAnnotation_Type.this);
+  	  }
+    };
+  /** @generated */
+  public final static int typeIndexID = SentenceAnnotation.typeIndexID;
+  /** @generated 
+     @modifiable */
+  public final static boolean featOkTst = JCasRegistry.getFeatOkTst("org.apache.uima.SentenceAnnotation");
+
+
+
+  /** initialize variables to correspond with Cas Type and Features
+	* @generated */
+  public SentenceAnnotation_Type(JCas jcas, Type casType) {
+    super(jcas, casType);
+    casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());
+
+  }
+}
+
+
+
+    
\ No newline at end of file

Added: uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/TokenAnnotation.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/TokenAnnotation.java?rev=992213&view=auto
==============================================================================
--- uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/TokenAnnotation.java
(added)
+++ uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/TokenAnnotation.java
Fri Sep  3 05:34:32 2010
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* First created by JCasGen Thu Sep 02 14:47:15 EDT 2010 */
+package org.apache.uima;
+
+import org.apache.uima.jcas.JCas; 
+import org.apache.uima.jcas.JCasRegistry;
+import org.apache.uima.jcas.cas.TOP_Type;
+
+import org.apache.uima.jcas.tcas.Annotation;
+
+
+/** Single token annotation
+ * Updated by JCasGen Thu Sep 02 14:47:15 EDT 2010
+ * XML source: D:/mavenAlign/sandbox-trunk-data/SnowballAnnotator/desc/SnowballAnnotator.xml
+ * @generated */
+public class TokenAnnotation extends Annotation {
+  /** @generated
+   * @ordered 
+   */
+  public final static int typeIndexID = JCasRegistry.register(TokenAnnotation.class);
+  /** @generated
+   * @ordered 
+   */
+  public final static int type = typeIndexID;
+  /** @generated  */
+  public              int getTypeIndexID() {return typeIndexID;}
+ 
+  /** Never called.  Disable default constructor
+   * @generated */
+  protected TokenAnnotation() {}
+    
+  /** Internal - constructor used by generator 
+   * @generated */
+  public TokenAnnotation(int addr, TOP_Type type) {
+    super(addr, type);
+    readObject();
+  }
+  
+  /** @generated */
+  public TokenAnnotation(JCas jcas) {
+    super(jcas);
+    readObject();   
+  } 
+
+  /** @generated */  
+  public TokenAnnotation(JCas jcas, int begin, int end) {
+    super(jcas);
+    setBegin(begin);
+    setEnd(end);
+    readObject();
+  }   
+
+  /** <!-- begin-user-doc -->
+    * Write your own initialization here
+    * <!-- end-user-doc -->
+  @generated modifiable */
+  private void readObject() {}
+     
+ 
+    
+  //*--------------*
+  //* Feature: stem
+
+  /** getter for stem - gets stem
+   * @generated */
+  public String getStem() {
+    if (TokenAnnotation_Type.featOkTst && ((TokenAnnotation_Type)jcasType).casFeat_stem
== null)
+      jcasType.jcas.throwFeatMissing("stem", "org.apache.uima.TokenAnnotation");
+    return jcasType.ll_cas.ll_getStringValue(addr, ((TokenAnnotation_Type)jcasType).casFeatCode_stem);}
+    
+  /** setter for stem - sets stem 
+   * @generated */
+  public void setStem(String v) {
+    if (TokenAnnotation_Type.featOkTst && ((TokenAnnotation_Type)jcasType).casFeat_stem
== null)
+      jcasType.jcas.throwFeatMissing("stem", "org.apache.uima.TokenAnnotation");
+    jcasType.ll_cas.ll_setStringValue(addr, ((TokenAnnotation_Type)jcasType).casFeatCode_stem,
v);}    
+  }
+
+    
\ No newline at end of file

Added: uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/TokenAnnotation_Type.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/TokenAnnotation_Type.java?rev=992213&view=auto
==============================================================================
--- uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/TokenAnnotation_Type.java
(added)
+++ uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/TokenAnnotation_Type.java
Fri Sep  3 05:34:32 2010
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* First created by JCasGen Thu Sep 02 14:47:15 EDT 2010 */
+package org.apache.uima;
+
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.JCasRegistry;
+import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.impl.FSGenerator;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.impl.FeatureImpl;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.jcas.tcas.Annotation_Type;
+
+/** Single token annotation
+ * Updated by JCasGen Thu Sep 02 14:47:15 EDT 2010
+ * @generated */
+public class TokenAnnotation_Type extends Annotation_Type {
+  /** @generated */
+  protected FSGenerator getFSGenerator() {return fsGenerator;}
+  /** @generated */
+  private final FSGenerator fsGenerator = 
+    new FSGenerator() {
+      public FeatureStructure createFS(int addr, CASImpl cas) {
+  			 if (TokenAnnotation_Type.this.useExistingInstance) {
+  			   // Return eq fs instance if already created
+  		     FeatureStructure fs = TokenAnnotation_Type.this.jcas.getJfsFromCaddr(addr);
+  		     if (null == fs) {
+  		       fs = new TokenAnnotation(addr, TokenAnnotation_Type.this);
+  			   TokenAnnotation_Type.this.jcas.putJfsFromCaddr(addr, fs);
+  			   return fs;
+  		     }
+  		     return fs;
+        } else return new TokenAnnotation(addr, TokenAnnotation_Type.this);
+  	  }
+    };
+  /** @generated */
+  public final static int typeIndexID = TokenAnnotation.typeIndexID;
+  /** @generated 
+     @modifiable */
+  public final static boolean featOkTst = JCasRegistry.getFeatOkTst("org.apache.uima.TokenAnnotation");
+ 
+  /** @generated */
+  final Feature casFeat_stem;
+  /** @generated */
+  final int     casFeatCode_stem;
+  /** @generated */ 
+  public String getStem(int addr) {
+        if (featOkTst && casFeat_stem == null)
+      jcas.throwFeatMissing("stem", "org.apache.uima.TokenAnnotation");
+    return ll_cas.ll_getStringValue(addr, casFeatCode_stem);
+  }
+  /** @generated */    
+  public void setStem(int addr, String v) {
+        if (featOkTst && casFeat_stem == null)
+      jcas.throwFeatMissing("stem", "org.apache.uima.TokenAnnotation");
+    ll_cas.ll_setStringValue(addr, casFeatCode_stem, v);}
+    
+  
+
+
+
+  /** initialize variables to correspond with Cas Type and Features
+	* @generated */
+  public TokenAnnotation_Type(JCas jcas, Type casType) {
+    super(jcas, casType);
+    casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());
+
+ 
+    casFeat_stem = jcas.getRequiredFeatureDE(casType, "stem", "uima.cas.String", featOkTst);
+    casFeatCode_stem  = (null == casFeat_stem) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_stem).getCode();
+
+  }
+}
+
+
+
+    
\ No newline at end of file

Modified: uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/annotator/SnowballAnnotator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/annotator/SnowballAnnotator.java?rev=992213&r1=992212&r2=992213&view=diff
==============================================================================
--- uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/annotator/SnowballAnnotator.java
(original)
+++ uima/sandbox/trunk/SnowballAnnotator/src/main/java/org/apache/uima/annotator/SnowballAnnotator.java
Fri Sep  3 05:34:32 2010
@@ -22,19 +22,15 @@ package org.apache.uima.annotator;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 
-import org.apache.uima.analysis_engine.ResultSpecification;
-import org.apache.uima.analysis_engine.annotator.AnnotatorConfigurationException;
-import org.apache.uima.analysis_engine.annotator.AnnotatorContext;
-import org.apache.uima.analysis_engine.annotator.AnnotatorInitializationException;
-import org.apache.uima.analysis_engine.annotator.AnnotatorProcessException;
-import org.apache.uima.analysis_engine.annotator.JTextAnnotator_ImplBase;
+import org.apache.uima.TokenAnnotation;
+import org.apache.uima.UimaContext;
+import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.cas.FSIterator;
-import org.apache.uima.cas.Feature;
-import org.apache.uima.cas.Type;
-import org.apache.uima.cas.TypeSystem;
-import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.cas.text.Language;
 import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.resource.ResourceInitializationException;
 import org.apache.uima.util.Level;
 import org.apache.uima.util.Logger;
 import org.tartarus.snowball.SnowballProgram;
@@ -52,35 +48,21 @@ import org.tartarus.snowball.ext.russian
 import org.tartarus.snowball.ext.spanishStemmer;
 import org.tartarus.snowball.ext.swedishStemmer;
 
-public class SnowballAnnotator extends JTextAnnotator_ImplBase {
-
-  private static final String TOKEN_ANNOTATION_NAME = "org.apache.uima.TokenAnnotation";
-
-  private static final String TOKEN_ANNOTATION_STEM_FEATURE_NAME = "stem";
-
-  private Type tokenAnnotation;
-
-  private Feature tokenAnnotationStemmFeature;
+public class SnowballAnnotator extends JCasAnnotator_ImplBase {
 
   private Logger logger;
 
-  private HashMap stemmers;
+  private HashMap<String,SnowballProgram> stemmers;
 
   private static final Object[] emptyArgs = new Object[0];
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.uima.analysis_engine.annotator.JTextAnnotator#process(org.apache.uima.jcas.impl.JCas,
-   *      org.apache.uima.analysis_engine.ResultSpecification)
-   */
-  public void process(JCas aJCas, ResultSpecification aResultSpec) throws AnnotatorProcessException
{
+  public void process(JCas aJCas) throws AnalysisEngineProcessException {
 
     this.logger.log(Level.INFO, "Snowball annotator starts processing");
 
     // get get stemmer for the document language
     String language = new Language(aJCas.getDocumentLanguage()).getLanguagePart();
-    SnowballProgram stemmer = (SnowballProgram) this.stemmers.get(language);
+    SnowballProgram stemmer = this.stemmers.get(language);
 
     // create stemms if stemmer for the current document language is available
     if (stemmer != null) {
@@ -90,14 +72,14 @@ public class SnowballAnnotator extends J
       try {
         stemmerStemMethod = stemmer.getClass().getMethod("stem", new Class[0]);
       } catch (Exception ex) {
-        throw new AnnotatorProcessException(ex);
+        throw new AnalysisEngineProcessException(ex);
       }
 
       // iterate over all token annotations and add stem if available
-      FSIterator tokenIterator = aJCas.getCas().getAnnotationIndex(this.tokenAnnotation).iterator();
+      FSIterator<Annotation> tokenIterator = aJCas.getAnnotationIndex(TokenAnnotation.type).iterator();
       while (tokenIterator.hasNext()) {
         // get token content
-        AnnotationFS annot = (AnnotationFS) tokenIterator.next();
+        TokenAnnotation annot = (TokenAnnotation) tokenIterator.next();
         String span = annot.getCoveredText();
 
         // set annotation content and call stemmer
@@ -105,28 +87,25 @@ public class SnowballAnnotator extends J
           stemmer.setCurrent(span);
           stemmerStemMethod.invoke(stemmer, emptyArgs);
         } catch (Exception ex) {
-          throw new AnnotatorProcessException(ex);
+          throw new AnalysisEngineProcessException(ex);
         }
 
         // get stemmer result and set annotation feature
-        annot.setStringValue(this.tokenAnnotationStemmFeature, stemmer.getCurrent());
+        annot.setStem(stemmer.getCurrent());
       }
     }
     this.logger.log(Level.INFO, "Snowball annotator processing finished");
   }
 
-  /* (non-Javadoc)
-   * @see org.apache.uima.analysis_engine.annotator.Annotator_ImplBase#initialize(org.apache.uima.analysis_engine.annotator.AnnotatorContext)
-   */
-  public void initialize(AnnotatorContext aContext) throws AnnotatorInitializationException,
-          AnnotatorConfigurationException {
-
+  @Override
+  public void initialize(UimaContext aContext) throws ResourceInitializationException {
+    super.initialize(aContext);
     // initialize logger
     try {
       this.logger = aContext.getLogger();
 
       // initialize stemmers
-      this.stemmers = new HashMap();
+      this.stemmers = new HashMap<String, SnowballProgram>();
       this.stemmers.put("da", new danishStemmer());
       this.stemmers.put("nl", new dutchStemmer());
       this.stemmers.put("en", new englishStemmer());
@@ -141,25 +120,9 @@ public class SnowballAnnotator extends J
       this.stemmers.put("es", new spanishStemmer());
       this.stemmers.put("sw", new swedishStemmer());
     } catch (Exception ex) {
-      throw new AnnotatorInitializationException(ex);
+      throw new ResourceInitializationException(ex);
     }
 
     this.logger.log(Level.INFO, "Snowball annotator successfully initialized");
   }
-
-  /* (non-Javadoc)
-   * @see org.apache.uima.analysis_engine.annotator.Annotator_ImplBase#typeSystemInit(org.apache.uima.cas.TypeSystem)
-   */
-  public void typeSystemInit(TypeSystem aTypeSystem) throws AnnotatorInitializationException,
-          AnnotatorConfigurationException {
-
-    // initialize cas token type
-    this.tokenAnnotation = aTypeSystem.getType(TOKEN_ANNOTATION_NAME);
-
-    this.tokenAnnotationStemmFeature = aTypeSystem.getFeatureByFullName(TOKEN_ANNOTATION_NAME
-            + TypeSystem.FEATURE_SEPARATOR + TOKEN_ANNOTATION_STEM_FEATURE_NAME);
-
-    this.logger.log(Level.INFO, "Snowball annotator typesystem initialized");
-  }
-
 }

Modified: uima/sandbox/trunk/SnowballAnnotator/src/test/java/org/apache/uima/annotator/SnowballAnnotatorTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/SnowballAnnotator/src/test/java/org/apache/uima/annotator/SnowballAnnotatorTest.java?rev=992213&r1=992212&r2=992213&view=diff
==============================================================================
--- uima/sandbox/trunk/SnowballAnnotator/src/test/java/org/apache/uima/annotator/SnowballAnnotatorTest.java
(original)
+++ uima/sandbox/trunk/SnowballAnnotator/src/test/java/org/apache/uima/annotator/SnowballAnnotatorTest.java
Fri Sep  3 05:34:32 2010
@@ -23,50 +23,69 @@ import java.io.File;
 
 import junit.framework.TestCase;
 
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.cas.CAS;
+import org.apache.uima.resource.ResourceSpecifier;
 import org.apache.uima.test.junit_extension.AnnotatorTester;
 import org.apache.uima.test.junit_extension.JUnitExtension;
-
+import org.apache.uima.util.XMLInputSource;
 
 /**
  * Testclass for the SnowballAnnotator.
  */
-public class SnowballAnnotatorTest extends TestCase
-{
-	private AnnotatorTester annotTester;
-	
-	/**
-	 * @see junit.framework.TestCase#setUp()
-	 */
-	protected void setUp() throws Exception
-	{
-		this.annotTester = new AnnotatorTester(JUnitExtension.getFile("SnowballAnnotator.xml"));
-	}
-
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception
-    {
-      super.tearDown();
-      this.annotTester = null;
-    }
-    
+public class SnowballAnnotatorTest extends TestCase {
+  private AnnotatorTester annotTester;
+
+  /**
+   * @see junit.framework.TestCase#setUp()
+   */
+  protected void setUp() throws Exception {
+    this.annotTester = new AnnotatorTester(JUnitExtension.getFile("SnowballAnnotator.xml"));
+  }
 
-  public void testAnnotatorEnglish() throws Exception
-  {
-    //get cas from xcas file
-    CAS cas = AnnotatorTester.getCASfromXCAS(JUnitExtension.getFile("typesystem.xml"), JUnitExtension.getFile("englishXCAS.xml"));
-    
-    //execute sample text
+  /*
+   * (non-Javadoc)
+   * 
+   * @see junit.framework.TestCase#tearDown()
+   */
+  protected void tearDown() throws Exception {
+    super.tearDown();
+    this.annotTester = null;
+  }
+
+  public void testAnnotatorEnglish() throws Exception {
+    // get cas from xcas file
+    CAS cas = AnnotatorTester.getCASfromXCAS(JUnitExtension.getFile("typesystem.xml"),
+            JUnitExtension.getFile("englishXCAS.xml"));
+
+    // execute sample text
     this.annotTester.performTest(cas);
-    
-    //define result interested in
-    String[] tofs = {"org.apache.uima.TokenAnnotation", "org.apache.uima.TokenAnnotation:stem"};
-    
-    //compare results
-    File outputFile = new File(JUnitExtension.getFile("englishRef.txt").getParent(), "englishRef_testoutput.txt")
;
-    AnnotatorTester.checkResult(cas, tofs, JUnitExtension.getFile("englishRef.txt"), outputFile);
  
+
+    // define result interested in
+    String[] tofs = { "org.apache.uima.TokenAnnotation", "org.apache.uima.TokenAnnotation:stem"
};
+
+    // compare results
+    File outputFile = new File(JUnitExtension.getFile("englishRef.txt").getParent(),
+            "englishRef_testoutput.txt");
+    AnnotatorTester.checkResult(cas, tofs, JUnitExtension.getFile("englishRef.txt"), outputFile);
   }
 
+  public void testReconfigure() {
+    try {
+      XMLInputSource in = new XMLInputSource("desc/SnowballAnnotator.xml");
+      ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
+
+      AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
+
+      CAS cas = AnnotatorTester.getCASfromXCAS(JUnitExtension.getFile("typesystem.xml"),
+              JUnitExtension.getFile("englishXCAS.xml"));
+
+      ae.process(cas);
+
+      ae.reconfigure();
+    } catch (Exception e) {
+      fail();
+    }
+  }
 }



Mime
View raw message