@Test void annotateMonth() { List<String> tokens = Collections.singletonList("May"); List<Rule> rules = DateTimeAnnotator.INSTANCE.annotate(tokens); assertEquals(rules.get(0).getLHS(), "$DATE_MONTH"); List<Map<String, Object>> result = rules.get(0).getSemantics().apply(Collections.emptyList()); assertTrue(result.get(0).containsKey("month")); assertEquals(result.get(0).get("month"), 5.0); }
@Override public List<Rule> annotate(List<String> tokens) { if(tokens.size() == 1) { String s = tokens.get(0).toLowerCase(); Rule r = parseMonth(s); if(r == null) r = parseDay(s); if(r == null) r = parseTime(s); if(r != null) return Collections.singletonList(r); else return parseNumber(s); } return Collections.emptyList(); }
DateTimeAnnotator implements Annotator { @Override public List<Rule> annotate(List<String> tokens) { if(tokens.size() == 1) { String s = tokens.get(0).toLowerCase(); Rule r = parseMonth(s); if(r == null) r = parseDay(s); if(r == null) r = parseTime(s); if(r != null) return Collections.singletonList(r); else return parseNumber(s); } return Collections.emptyList(); } }
DateTimeAnnotator implements Annotator { @Override public List<Rule> annotate(List<String> tokens) { if(tokens.size() == 1) { String s = tokens.get(0).toLowerCase(); Rule r = parseMonth(s); if(r == null) r = parseDay(s); if(r == null) r = parseTime(s); if(r != null) return Collections.singletonList(r); else return parseNumber(s); } return Collections.emptyList(); } private  DateTimeAnnotator(); }
DateTimeAnnotator implements Annotator { @Override public List<Rule> annotate(List<String> tokens) { if(tokens.size() == 1) { String s = tokens.get(0).toLowerCase(); Rule r = parseMonth(s); if(r == null) r = parseDay(s); if(r == null) r = parseTime(s); if(r != null) return Collections.singletonList(r); else return parseNumber(s); } return Collections.emptyList(); } private  DateTimeAnnotator(); @Override List<Rule> annotate(List<String> tokens); static List<Rule> rules(); }
DateTimeAnnotator implements Annotator { @Override public List<Rule> annotate(List<String> tokens) { if(tokens.size() == 1) { String s = tokens.get(0).toLowerCase(); Rule r = parseMonth(s); if(r == null) r = parseDay(s); if(r == null) r = parseTime(s); if(r != null) return Collections.singletonList(r); else return parseNumber(s); } return Collections.emptyList(); } private  DateTimeAnnotator(); @Override List<Rule> annotate(List<String> tokens); static List<Rule> rules(); static final Annotator INSTANCE; }