@Test public void testThisX() throws Exception { jCas.setDocumentText("This week is part of this month, which is part of this year."); setDocumentDate(); processJCas(); assertEquals(3, JCasUtil.select(jCas, Temporal.class).size()); Temporal t1 = JCasUtil.selectByIndex(jCas, Temporal.class, 0); assertEquals("This week", t1.getCoveredText()); assertEquals( LocalDate.of(2016, 10, 3).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t1.getTimestampStart()); assertEquals( LocalDate.of(2016, 10, 10).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t1.getTimestampStop()); Temporal t2 = JCasUtil.selectByIndex(jCas, Temporal.class, 1); assertEquals("this month", t2.getCoveredText()); assertEquals( LocalDate.of(2016, 10, 1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t2.getTimestampStart()); assertEquals( LocalDate.of(2016, 11, 1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t2.getTimestampStop()); Temporal t3 = JCasUtil.selectByIndex(jCas, Temporal.class, 2); assertEquals("this year", t3.getCoveredText()); assertEquals( LocalDate.of(2016, 1, 1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t3.getTimestampStart()); assertEquals( LocalDate.of(2017, 1, 1).atStartOfDay().toEpochSecond(ZoneOffset.UTC), t3.getTimestampStop()); }
private void thisX(TextBlock block) { Pattern p = Pattern.compile("\\bthis (week|month|year)\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if ("week".equalsIgnoreCase(m.group(1))) { createRelativeWeek(block, m.start(), m.end(), 0); } else if ("month".equalsIgnoreCase(m.group(1))) { createRelativeMonth(block, m.start(), m.end(), 0); } else if ("year".equalsIgnoreCase(m.group(1))) { createRelativeYear(block, m.start(), m.end(), 0); } } }
RelativeDate extends BaleenTextAwareAnnotator { private void thisX(TextBlock block) { Pattern p = Pattern.compile("\\bthis (week|month|year)\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if ("week".equalsIgnoreCase(m.group(1))) { createRelativeWeek(block, m.start(), m.end(), 0); } else if ("month".equalsIgnoreCase(m.group(1))) { createRelativeMonth(block, m.start(), m.end(), 0); } else if ("year".equalsIgnoreCase(m.group(1))) { createRelativeYear(block, m.start(), m.end(), 0); } } } }
RelativeDate extends BaleenTextAwareAnnotator { private void thisX(TextBlock block) { Pattern p = Pattern.compile("\\bthis (week|month|year)\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if ("week".equalsIgnoreCase(m.group(1))) { createRelativeWeek(block, m.start(), m.end(), 0); } else if ("month".equalsIgnoreCase(m.group(1))) { createRelativeMonth(block, m.start(), m.end(), 0); } else if ("year".equalsIgnoreCase(m.group(1))) { createRelativeYear(block, m.start(), m.end(), 0); } } }  }
RelativeDate extends BaleenTextAwareAnnotator { private void thisX(TextBlock block) { Pattern p = Pattern.compile("\\bthis (week|month|year)\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if ("week".equalsIgnoreCase(m.group(1))) { createRelativeWeek(block, m.start(), m.end(), 0); } else if ("month".equalsIgnoreCase(m.group(1))) { createRelativeMonth(block, m.start(), m.end(), 0); } else if ("year".equalsIgnoreCase(m.group(1))) { createRelativeYear(block, m.start(), m.end(), 0); } } }  @Override AnalysisEngineAction getAction(); }
RelativeDate extends BaleenTextAwareAnnotator { private void thisX(TextBlock block) { Pattern p = Pattern.compile("\\bthis (week|month|year)\\b", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(block.getCoveredText()); while (m.find()) { if ("week".equalsIgnoreCase(m.group(1))) { createRelativeWeek(block, m.start(), m.end(), 0); } else if ("month".equalsIgnoreCase(m.group(1))) { createRelativeMonth(block, m.start(), m.end(), 0); } else if ("year".equalsIgnoreCase(m.group(1))) { createRelativeYear(block, m.start(), m.end(), 0); } } }  @Override AnalysisEngineAction getAction(); static final String PARAM_DATE_FORMAT; static final String PARAM_METADATA_FIELDS; }