@Test void applyLexicalRules() { List<Rule> rules = Collections.singletonList(new Rule("$A", "B C")); Grammar grammar = new Grammar(rules, "$ROOT"); Parser p = new Parser(grammar, null, null); Parser.Chart chart = p.new Chart(10); List<String> tokens = Arrays.asList("A", "B", "C"); p.applyLexicalRules(chart, tokens, 1, 3); assertEquals(rules.get(0), chart.getDerivations(1, 3).get(0).rule); }
void applyLexicalRules(Chart chart, List<String> tokens, int start, int end) { for(Rule rule: grammar.getLexicalRules(tokens.subList(start, end))) { chart.addDerivation(start, end, new Derivation(rule, null)); } }
Parser { void applyLexicalRules(Chart chart, List<String> tokens, int start, int end) { for(Rule rule: grammar.getLexicalRules(tokens.subList(start, end))) { chart.addDerivation(start, end, new Derivation(rule, null)); } } }
Parser { void applyLexicalRules(Chart chart, List<String> tokens, int start, int end) { for(Rule rule: grammar.getLexicalRules(tokens.subList(start, end))) { chart.addDerivation(start, end, new Derivation(rule, null)); } } Parser(Grammar grammar, Tokenizer tokenizer, List<Annotator> annotators); }
Parser { void applyLexicalRules(Chart chart, List<String> tokens, int start, int end) { for(Rule rule: grammar.getLexicalRules(tokens.subList(start, end))) { chart.addDerivation(start, end, new Derivation(rule, null)); } } 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); }
Parser { void applyLexicalRules(Chart chart, List<String> tokens, int start, int end) { for(Rule rule: grammar.getLexicalRules(tokens.subList(start, end))) { chart.addDerivation(start, end, new Derivation(rule, null)); } } 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);  }