RelativeDate extends BaleenTextAwareAnnotator { private void yesterday(TextBlock block) { Pattern p = Pattern.compile("\\b(day before )?yesterday\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if (m.group(1) != null) { createRelativeDay(block, m.start(), m.end(), -2); } else { createRelativeDay(block, m.start(), m.end(), -1); } } }  @Override AnalysisEngineAction getAction(); static final String PARAM_DATE_FORMAT; static final String PARAM_METADATA_FIELDS; }
@Test public void testYesterday() throws Exception { jCas.setDocumentText("Yesterday was Tuesday, and the day before yesterday was Monday"); setDocumentDate(); processJCas(); assertEquals(2, JCasUtil.select(jCas, Temporal.class).size()); Temporal t1 = JCasUtil.selectByIndex(jCas, Temporal.class, 0); assertEquals("Yesterday", t1.getCoveredText()); assertEquals( relativeTo.minusDays(1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t1.getTimestampStart()); assertEquals(relativeTo.atStartOfDay().toEpochSecond(ZoneOffset.UTC), t1.getTimestampStop()); Temporal t2 = JCasUtil.selectByIndex(jCas, Temporal.class, 1); assertEquals("day before yesterday", t2.getCoveredText()); assertEquals( relativeTo.minusDays(2).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t2.getTimestampStart()); assertEquals( relativeTo.minusDays(1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t2.getTimestampStop()); }