package pipelines;

import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription;
import static org.apache.uima.fit.factory.ExternalResourceFactory.createExternalResourceDescription;
import static org.apache.uima.fit.pipeline.SimplePipeline.runPipeline;

import java.io.File;

import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ExternalResourceDescription;

import resources.AnnotatedCollection_Impl;
import resources.FeaturesList_Impl;
import annotators.FeaturesAnnotator;
import annotators.WekaModelBuilder;

public class ModelCreator {
	
	public static void main(String[] args) throws Exception {
		ExternalResourceDescription candidatesResourceDesc = createExternalResourceDescription(AnnotatedCollection_Impl.class,
				 "file:target/candidates.txt");
		ExternalResourceDescription featuresResourceDesc = createExternalResourceDescription(FeaturesList_Impl.class,
		         new File("features.bin"));
		System.out.println("Loaded");
		
		AnalysisEngineDescription ae_Features = createEngineDescription(FeaturesAnnotator.class,
		        FeaturesAnnotator.CANDIDATE_KEY,
		        candidatesResourceDesc,
		        FeaturesAnnotator.FEATURES_KEY,
		        featuresResourceDesc);
		
		AnalysisEngineDescription ae_Model = createEngineDescription(WekaModelBuilder.class,
		        WekaModelBuilder.FEATURES_KEY,
		        featuresResourceDesc);
		
		AnalysisEngineDescription aed = createEngineDescription(ae_Features, ae_Model);
		
		AnalysisEngine ae = createEngine(aed);
		
		JCas jcas = ae.newJCas();
		
		runPipeline(jcas, ae);
	  }

}
@@ -172,32 +172,112 @@
 ineDescription;%0A
+import static org.apache.uima.fit.factory.CollectionReaderFactory.createReader;%0A
 import static or
@@ -572,24 +572,76 @@
 escription;%0A
+import org.apache.uima.collection.CollectionReader;%0A
 import org.a
@@ -724,16 +724,48 @@
 ption;%0A%0A
+import readers.CandidateReader;%0A
 import r
@@ -1346,45 +1346,34 @@
 %09%0A%09%09
-AnalysisEngineDescription
+CollectionReader
  ae_
-Features
+Reader
  = c
@@ -1381,200 +1381,273 @@
 eate
-EngineDescription(FeaturesAnnotator.class,%0A%09%09        FeaturesAnnotator.CANDIDATE_KEY,%0A%09%09        candidatesResourceDesc,%0A%09%09        FeaturesAnnotator.FEATURES_KEY,%0A%09%09        featuresResourceDesc
+Reader(CandidateReader.class,%0A%09%09%09%09CandidateReader.CANDIDATE_KEY,%0A%09%09        candidatesResourceDesc,%0A%09%09        CandidateReader.PARAM_DIRECTORY,%0A%09%09        %22train/keys/%22%0A%09%09%09%09);%0A%09%09%0A%09%09AnalysisEngineDescription ae_Features = createEngineDescription(FeaturesAnnotator.class
 );%0A%09
@@ -1737,81 +1737,8 @@
 lass
-,%0A%09%09        WekaModelBuilder.FEATURES_KEY,%0A%09%09        featuresResourceDesc
 );%0A%09
@@ -1872,39 +1872,8 @@
 %0A%09%09%0A
-%09%09JCas jcas = ae.newJCas();%0A%09%09%0A
 %09%09ru
@@ -1882,20 +1882,25 @@
 ipeline(
-jcas
+ae_Reader
 , ae);%0A%09

Update the pipeline