MalletCrfStringOutcomeClassifier extends
    SequenceClassifier_ImplBase<List<NameNumber>, String, String> { public List<String> classify(List<List<Feature>> features) throws CleartkProcessingException { String[][] featureStringArray = toStrings(features); Pipe pipe = transducer.getInputPipe(); Instance instance = new Instance(featureStringArray, null, null, null); instance = pipe.instanceFrom(instance); Sequence<?> data = (Sequence<?>) instance.getData(); Sequence<?> untypedSequence = transducer.transduce(data); Sequence<String> sequence = ReflectionUtil.uncheckedCast(untypedSequence); List<String> returnValues = new ArrayList<String>(); for (int i = 0; i < sequence.size(); i++) { String encodedOutcome = sequence.get(i); returnValues.add(outcomeEncoder.decode(encodedOutcome)); } return returnValues; } MalletCrfStringOutcomeClassifier(
      FeaturesEncoder<List<NameNumber>> featuresEncoder,
      OutcomeEncoder<String, String> outcomeEncoder,
      Transducer transducer); List<String> classify(List<List<Feature>> features);  }
@Test public void runTest1() throws Exception { AnalysisEngine dataWriterAnnotator = AnalysisEngineFactory.createEngine( TestAnnotator.class, DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY, outputDirectoryName, DefaultSequenceDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME, MalletCrfStringOutcomeDataWriter.class.getName()); dataWriterAnnotator.process(jCas); dataWriterAnnotator.collectionProcessComplete(); File trainFile = new MalletCrfStringOutcomeClassifierBuilder().getTrainingDataFile(this.outputDirectory); BufferedReader reader = new BufferedReader(new FileReader(trainFile)); reader.readLine(); reader.close(); HideOutput hider = new HideOutput(); Train.main(outputDirectoryName); hider.restoreOutput(); MalletCrfStringOutcomeClassifierBuilder builder = new MalletCrfStringOutcomeClassifierBuilder(); MalletCrfStringOutcomeClassifier classifier; classifier = builder.loadClassifierFromTrainingDirectory(this.outputDirectory); List<List<Feature>> sequenceFeatures = new ArrayList<List<Feature>>(); List<Instance<String>> instances = createInstances(); for (Instance<String> instance : instances) { sequenceFeatures.add(instance.getFeatures()); } List<String> outcomes = classifier.classify(sequenceFeatures); assertEquals(sequenceFeatures.size(), outcomes.size()); testLabels( outcomes, "O O O O O O O O O O O O O O O B-GENE I-GENE I-GENE O B-GENE I-GENE O O O O O O O O O O O O O O O O O O O O O"); AnalysisEngine classifierAnnotator = AnalysisEngineFactory.createEngine( TestAnnotator.class, GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH, JarClassifierBuilder.getModelJarFile(outputDirectoryName)); jCas.reset(); classifierAnnotator.process(jCas); classifierAnnotator.collectionProcessComplete(); }