@Test public void testNextLastMonth() throws Exception { jCas.setDocumentText("Last month was September, and next month is November"); setDocumentDate(); processJCas(); assertEquals(2, JCasUtil.select(jCas, Temporal.class).size()); Temporal t1 = JCasUtil.selectByIndex(jCas, Temporal.class, 0); assertEquals("Last month", t1.getCoveredText()); assertEquals( LocalDate.of(2016, 9, 1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t1.getTimestampStart()); assertEquals( LocalDate.of(2016, 10, 1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t1.getTimestampStop()); Temporal t2 = JCasUtil.selectByIndex(jCas, Temporal.class, 1); assertEquals("next month", t2.getCoveredText()); assertEquals( LocalDate.of(2016, 11, 1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t2.getTimestampStart()); assertEquals( LocalDate.of(2016, 12, 1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t2.getTimestampStop()); }
private void nextLastMonth(TextBlock block) { Pattern p = Pattern.compile("\\b((in the|within the) )?(next|last) month\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if (m.group(2) != null) { if ("next".equalsIgnoreCase(m.group(3))) { createRelativeMonthPeriod(block, m.start(), m.end(), 1); } else { createRelativeMonthPeriod(block, m.start(), m.end(), -1); } } else { if ("next".equalsIgnoreCase(m.group(3))) { createRelativeMonth(block, m.start(), m.end(), 1); } else { createRelativeMonth(block, m.start(), m.end(), -1); } } } }
RelativeDate extends BaleenTextAwareAnnotator { private void nextLastMonth(TextBlock block) { Pattern p = Pattern.compile("\\b((in the|within the) )?(next|last) month\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if (m.group(2) != null) { if ("next".equalsIgnoreCase(m.group(3))) { createRelativeMonthPeriod(block, m.start(), m.end(), 1); } else { createRelativeMonthPeriod(block, m.start(), m.end(), -1); } } else { if ("next".equalsIgnoreCase(m.group(3))) { createRelativeMonth(block, m.start(), m.end(), 1); } else { createRelativeMonth(block, m.start(), m.end(), -1); } } } } }
RelativeDate extends BaleenTextAwareAnnotator { private void nextLastMonth(TextBlock block) { Pattern p = Pattern.compile("\\b((in the|within the) )?(next|last) month\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if (m.group(2) != null) { if ("next".equalsIgnoreCase(m.group(3))) { createRelativeMonthPeriod(block, m.start(), m.end(), 1); } else { createRelativeMonthPeriod(block, m.start(), m.end(), -1); } } else { if ("next".equalsIgnoreCase(m.group(3))) { createRelativeMonth(block, m.start(), m.end(), 1); } else { createRelativeMonth(block, m.start(), m.end(), -1); } } } }  }
RelativeDate extends BaleenTextAwareAnnotator { private void nextLastMonth(TextBlock block) { Pattern p = Pattern.compile("\\b((in the|within the) )?(next|last) month\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if (m.group(2) != null) { if ("next".equalsIgnoreCase(m.group(3))) { createRelativeMonthPeriod(block, m.start(), m.end(), 1); } else { createRelativeMonthPeriod(block, m.start(), m.end(), -1); } } else { if ("next".equalsIgnoreCase(m.group(3))) { createRelativeMonth(block, m.start(), m.end(), 1); } else { createRelativeMonth(block, m.start(), m.end(), -1); } } } }  @Override AnalysisEngineAction getAction(); }
RelativeDate extends BaleenTextAwareAnnotator { private void nextLastMonth(TextBlock block) { Pattern p = Pattern.compile("\\b((in the|within the) )?(next|last) month\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if (m.group(2) != null) { if ("next".equalsIgnoreCase(m.group(3))) { createRelativeMonthPeriod(block, m.start(), m.end(), 1); } else { createRelativeMonthPeriod(block, m.start(), m.end(), -1); } } else { if ("next".equalsIgnoreCase(m.group(3))) { createRelativeMonth(block, m.start(), m.end(), 1); } else { createRelativeMonth(block, m.start(), m.end(), -1); } } } }  @Override AnalysisEngineAction getAction(); static final String PARAM_DATE_FORMAT; static final String PARAM_METADATA_FIELDS; }