TempEval2007Writer extends JCasAnnotator_ImplBase { public static String toTimeML(JCas jCas) throws AnalysisEngineProcessException { try { return toXML(jCas.getCas(), new TimeMlAnnotationsToElements()); } catch (SAXException e) { throw new AnalysisEngineProcessException(e); } }  static AnalysisEngineDescription getDescription(String outputDir); @Override void initialize(UimaContext context); static String toTimeML(JCas jCas); @Override void process(JCas jCas); void setOutputDirectoryName(String outputDirectoryName); static final String PARAM_OUTPUT_DIRECTORY_NAME; }
@Test public void testToTimeML() throws Throwable { this.jCas.setDocumentText("\nHe bought milk yesterday.\n\n\n"); Event event = new Event(this.jCas, 4, 10); event.setId("e1"); event.setEventInstanceID("ei1"); event.addToIndexes(); Assert.assertEquals("bought", event.getCoveredText()); Time time = new Time(this.jCas, 16, 25); time.setId("t1"); time.addToIndexes(); Assert.assertEquals("yesterday", time.getCoveredText()); TemporalLink tlink1 = new TemporalLink(this.jCas, 27, 27); tlink1.setSource(event); tlink1.setTarget(time); tlink1.setRelationType("OVERLAP"); tlink1.addToIndexes(); TemporalLink tlink2 = new TemporalLink(this.jCas, 28, 28); tlink2.setSource(time); tlink2.setTarget(event); tlink2.setRelationType("OVERLAP"); tlink2.addToIndexes(); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><TimeML>\n" + "He <EVENT eid=\"e1\">bought</EVENT> milk <TIMEX3 tid=\"t1\">yesterday</TIMEX3>.\n" + "<TLINK relType=\"OVERLAP\" eventID=\"e1\" relatedToTime=\"t1\"/>\n" + "<TLINK relType=\"OVERLAP\" timeID=\"t1\" relatedToEvent=\"e1\"/>\n" + "</TimeML>"; Assert.assertEquals(expected, TempEval2007Writer.toTimeML(this.jCas).replaceAll("\r", "")); }