### Question:
Parser { void applyBinaryRules(Chart chart, int start, int end) { if(end > start + 1) { for(int mid = start + 1; mid < end; mid++) { List<Derivation> left = chart.getDerivations(start, mid); List<Derivation> right = chart.getDerivations(mid, end); for(Derivation l:left) { for(Derivation r: right) { for(Rule rule: grammar.getBinaryRules(l.rule.getLHS(), r.rule.getLHS())) { if(chart.isSpanFull(start, end)) return; chart.addDerivation(start, end, new Derivation(rule, Arrays.asList(l, r))); } } } } } } Parser(Grammar grammar, Tokenizer tokenizer, List<Annotator> annotators); Map<String, Float> getWeights(); void setWeights(Map<String, Float> weights); List<Derivation> parseSyntactic(String input); List<LogicalForm> parse(String input); LogicalForm computeLogicalForm(Derivation d);  }### Answer:
@Test void applyBinaryRules() { List<Rule> rules = Collections.singletonList( new Rule("$C", "$A $B")); Grammar grammar = new Grammar(rules, "$ROOT"); Parser p = new Parser(grammar, null, null); Parser.Chart chart = p.new Chart(10); chart.addDerivation(0, 1, new Derivation(new Rule("$A", "A"), null)); chart.addDerivation(1, 2, new Derivation(new Rule("$B", "B"), null)); p.applyBinaryRules(chart, 0, 2); assertEquals(rules.get(0), chart.getDerivations(0, 2).get(0).rule); }