@Test void annotate() { Annotator annotator = new NumberAnnotator(); List<String> tokens = Collections.singletonList("123"); List<Rule> actual = annotator.annotate(tokens); assertEquals(1, actual.size()); assertEquals("$NUMBER", actual.get(0).getLHS()); assertEquals("123", actual.get(0).getRHS().toString()); assertEquals(123.0, actual.get(0) .getSemantics().apply(null) .get(0).get(SemanticUtils.KEY_UNNAMED)); }
@Override public List<Rule> annotate(List<String> tokens) { if(tokens.size() == 1) { try { String n = tokens.get(0); Object f = Double.valueOf(n); return Collections.singletonList(new Rule(SYMBOL, n, SemanticUtils.value(f))); }catch(NumberFormatException e) { } } return Collections.emptyList(); }
NumberAnnotator implements Annotator { @Override public List<Rule> annotate(List<String> tokens) { if(tokens.size() == 1) { try { String n = tokens.get(0); Object f = Double.valueOf(n); return Collections.singletonList(new Rule(SYMBOL, n, SemanticUtils.value(f))); }catch(NumberFormatException e) { } } return Collections.emptyList(); } }
NumberAnnotator implements Annotator { @Override public List<Rule> annotate(List<String> tokens) { if(tokens.size() == 1) { try { String n = tokens.get(0); Object f = Double.valueOf(n); return Collections.singletonList(new Rule(SYMBOL, n, SemanticUtils.value(f))); }catch(NumberFormatException e) { } } return Collections.emptyList(); }  }
NumberAnnotator implements Annotator { @Override public List<Rule> annotate(List<String> tokens) { if(tokens.size() == 1) { try { String n = tokens.get(0); Object f = Double.valueOf(n); return Collections.singletonList(new Rule(SYMBOL, n, SemanticUtils.value(f))); }catch(NumberFormatException e) { } } return Collections.emptyList(); }  @Override List<Rule> annotate(List<String> tokens); }
NumberAnnotator implements Annotator { @Override public List<Rule> annotate(List<String> tokens) { if(tokens.size() == 1) { try { String n = tokens.get(0); Object f = Double.valueOf(n); return Collections.singletonList(new Rule(SYMBOL, n, SemanticUtils.value(f))); }catch(NumberFormatException e) { } } return Collections.emptyList(); }  @Override List<Rule> annotate(List<String> tokens); static final Annotator INSTANCE; }