@Test public void test1() throws Exception { AnalysisEngine dataWriterAnnotator = AnalysisEngineFactory.createEngine( Test1Annotator.class, DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY, outputDirectoryName, DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME, MaxentBooleanOutcomeDataWriter.class.getName()); dataWriterAnnotator.process(jCas); dataWriterAnnotator.collectionProcessComplete(); File trainFile = new MaxentBooleanOutcomeClassifierBuilder().getTrainingDataFile(this.outputDirectory); String[] lines = FileUtil.loadListOfStrings(trainFile); assertEquals("true pos_NN distance=3.0 precision=1.234", lines[0]); assertEquals("false name_2PO p's=2.0", lines[1]); assertEquals("true null=0.0", lines[2]); assertEquals("false A_B_AB", lines[3]); // simply train four different models where each one writes over the previous HideOutput hider = new HideOutput(); Train.main(outputDirectoryName, "10", "1"); hider.restoreOutput(); }
@Test public void testAnnotatorDescriptor() throws Exception { HideOutput hider = new HideOutput(); BuildTestExamplePosModel.main(); hider.restoreOutput(); String modelFileName = JarClassifierBuilder.getModelJarFile(ExamplePosAnnotator.DEFAULT_OUTPUT_DIRECTORY) .getPath(); AnalysisEngineDescription posTaggerDescription = ExamplePosAnnotator.getClassifierDescription(modelFileName); AnalysisEngine engine = AnalysisEngineFactory.createEngine(posTaggerDescription); Object classifierJar = engine.getConfigParameterValue(GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH); Assert.assertEquals(modelFileName, classifierJar); engine.collectionProcessComplete(); }
/** Here we test that an exception is thrown if an instance with no outcome */ @Test public void test4() throws Exception { HideOutput hider = new HideOutput(); AnalysisEngine dataWriterAnnotator = AnalysisEngineFactory.createEngine( Test4Annotator.class, DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY, outputDirectoryName, DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME, MaxentBooleanOutcomeDataWriter.class.getName()); AnalysisEngineProcessException aepe = null; try { dataWriterAnnotator.process(jCas); } catch (AnalysisEngineProcessException e) { aepe = e; } dataWriterAnnotator.collectionProcessComplete(); assertNotNull(aepe); hider.restoreOutput(); }