Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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.
 
 package org.apache.ctakes.temporal.ae;
 
 import java.io.File;
 import java.util.List;
 
 import  org.cleartk.ml.CleartkAnnotator;
 import  org.cleartk.ml.DataWriter;
 import  org.cleartk.ml.Feature;
 import  org.cleartk.ml.Instance;
 import  org.cleartk.ml.feature.extractor.CleartkExtractor;
 import  org.cleartk.ml.feature.extractor.CleartkExtractor.Covered;
 import  org.cleartk.ml.feature.extractor.CleartkExtractor.Following;
 import  org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding;
 import  org.cleartk.ml.feature.extractor.CombinedExtractor1;
 import  org.cleartk.ml.feature.extractor.CoveredTextExtractor;
 import  org.cleartk.ml.feature.extractor.TypePathExtractor;
 import  org.cleartk.ml.jar.DefaultDataWriterFactory;
 import  org.cleartk.ml.jar.DirectoryDataWriterFactory;
 import  org.cleartk.ml.jar.GenericJarClassifierFactory;
 
 public class ContextualModalityAnnotator extends CleartkAnnotator<String> {
       Class<? extends DataWriter<String>> dataWriterClass,
       File outputDirectorythrows ResourceInitializationException {
     return AnalysisEngineFactory.createEngineDescription(
         ContextualModalityAnnotator.class,
         CleartkAnnotator.PARAM_IS_TRAINING,
         true,
         DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
         dataWriterClass,
         DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY,
         outputDirectory);
   }
   
 	      throws ResourceInitializationException {
 	    return AnalysisEngineFactory.createEngineDescription(
 	        ContextualModalityAnnotator.class,
 	        CleartkAnnotator.PARAM_IS_TRAINING,
 	        false,
 	        GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
 	        modelPath);
 	  }
  
  

Deprecated:
use String path instead of File. ClearTK will automatically Resolve the String to an InputStream. This will allow resources to be read within from a jar as well as File.
 
   public static AnalysisEngineDescription createAnnotatorDescription(File modelDirectory)
       throws ResourceInitializationException {
     return AnalysisEngineFactory.createEngineDescription(
         ContextualModalityAnnotator.class,
         CleartkAnnotator.PARAM_IS_TRAINING,
         false,
         GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
         new File(modelDirectory"model.jar"));
   }
 
   private CleartkExtractor contextExtractor;
 
   @Override
   public void initialize(UimaContext contextthrows ResourceInitializationException {
     super.initialize(context);
     CombinedExtractor1 baseExtractor = new CombinedExtractor1(
         new CoveredTextExtractor(),
         new TypePathExtractor(BaseToken.class"partOfSpeech"));
 
     this. = new CleartkExtractor(
         BaseToken.class,
         baseExtractor,
         new Preceding(3),
        new Covered(),
        new Following(3));
  }
  
  public void process(JCas jCasthrows AnalysisEngineProcessException {
    for (EventMention eventMention : JCasUtil.select(jCasEventMention.class)) {
      if (eventMention.getEvent() != null) {
        List<Feature> features = this..extract(jCaseventMention);
        if (this.isTraining()) {
          String outcome = eventMention.getEvent().getProperties().getContextualModality();
          this..write(new Instance<String>(outcomefeatures));
        } else {
          String outcome = this..classify(features);
          eventMention.getEvent().getProperties().setContextualModality(outcome);
        }
      }
    }
  }
New to GrepCode? Check out our FAQ X