@Test public void testNextLastDay() throws Exception { jCas.setDocumentText("Next Friday is in two days time. Last Wednesday was seven days ago."); setDocumentDate(); processJCas(); assertEquals(2, JCasUtil.select(jCas, Temporal.class).size()); Temporal t1 = JCasUtil.selectByIndex(jCas, Temporal.class, 0); assertEquals("Next Friday", t1.getCoveredText()); assertEquals( relativeTo.plusDays(2).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t1.getTimestampStart()); assertEquals( relativeTo.plusDays(3).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t1.getTimestampStop()); Temporal t2 = JCasUtil.selectByIndex(jCas, Temporal.class, 1); assertEquals("Last Wednesday", t2.getCoveredText()); assertEquals( relativeTo.minusWeeks(1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t2.getTimestampStart()); assertEquals( relativeTo.minusDays(6).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t2.getTimestampStop()); }
private void nextLastDay(TextBlock block) { Pattern p = Pattern.compile("\\b(next|last) " + DAYS + "\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { Integer offset = null; if (relativeTo != null) { if ("next".equalsIgnoreCase(m.group(1))) { for (int i = 1; i <= 7; i++) { if (relativeTo.plusDays(i).getDayOfWeek() == DateTimeUtils.asDay(m.group(2))) { offset = i; break; } } } else { for (int i = 1; i <= 7; i++) { if (relativeTo.minusDays(i).getDayOfWeek() == DateTimeUtils.asDay(m.group(2))) { offset = -i; break; } } } } createRelativeDay(block, m.start(), m.end(), offset); } }
RelativeDate extends BaleenTextAwareAnnotator { private void nextLastDay(TextBlock block) { Pattern p = Pattern.compile("\\b(next|last) " + DAYS + "\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { Integer offset = null; if (relativeTo != null) { if ("next".equalsIgnoreCase(m.group(1))) { for (int i = 1; i <= 7; i++) { if (relativeTo.plusDays(i).getDayOfWeek() == DateTimeUtils.asDay(m.group(2))) { offset = i; break; } } } else { for (int i = 1; i <= 7; i++) { if (relativeTo.minusDays(i).getDayOfWeek() == DateTimeUtils.asDay(m.group(2))) { offset = -i; break; } } } } createRelativeDay(block, m.start(), m.end(), offset); } } }
RelativeDate extends BaleenTextAwareAnnotator { private void nextLastDay(TextBlock block) { Pattern p = Pattern.compile("\\b(next|last) " + DAYS + "\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { Integer offset = null; if (relativeTo != null) { if ("next".equalsIgnoreCase(m.group(1))) { for (int i = 1; i <= 7; i++) { if (relativeTo.plusDays(i).getDayOfWeek() == DateTimeUtils.asDay(m.group(2))) { offset = i; break; } } } else { for (int i = 1; i <= 7; i++) { if (relativeTo.minusDays(i).getDayOfWeek() == DateTimeUtils.asDay(m.group(2))) { offset = -i; break; } } } } createRelativeDay(block, m.start(), m.end(), offset); } }  }
RelativeDate extends BaleenTextAwareAnnotator { private void nextLastDay(TextBlock block) { Pattern p = Pattern.compile("\\b(next|last) " + DAYS + "\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { Integer offset = null; if (relativeTo != null) { if ("next".equalsIgnoreCase(m.group(1))) { for (int i = 1; i <= 7; i++) { if (relativeTo.plusDays(i).getDayOfWeek() == DateTimeUtils.asDay(m.group(2))) { offset = i; break; } } } else { for (int i = 1; i <= 7; i++) { if (relativeTo.minusDays(i).getDayOfWeek() == DateTimeUtils.asDay(m.group(2))) { offset = -i; break; } } } } createRelativeDay(block, m.start(), m.end(), offset); } }  @Override AnalysisEngineAction getAction(); }
RelativeDate extends BaleenTextAwareAnnotator { private void nextLastDay(TextBlock block) { Pattern p = Pattern.compile("\\b(next|last) " + DAYS + "\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { Integer offset = null; if (relativeTo != null) { if ("next".equalsIgnoreCase(m.group(1))) { for (int i = 1; i <= 7; i++) { if (relativeTo.plusDays(i).getDayOfWeek() == DateTimeUtils.asDay(m.group(2))) { offset = i; break; } } } else { for (int i = 1; i <= 7; i++) { if (relativeTo.minusDays(i).getDayOfWeek() == DateTimeUtils.asDay(m.group(2))) { offset = -i; break; } } } } createRelativeDay(block, m.start(), m.end(), offset); } }  @Override AnalysisEngineAction getAction(); static final String PARAM_DATE_FORMAT; static final String PARAM_METADATA_FIELDS; }