@Test public void testApplyRule() { List<List<String>> results = rule.applyRule(tree); for (List<String> result : results) { StringBuilder sb = new StringBuilder(); for (String r : result) sb.append(r).append(" "); assertTrue(afterRule.contains(sb.toString().trim())); } }
public List<List<T>> applyRule(Tree<T> tree) { List<List<T>> output = new ArrayList<>(); if (!matcher.matches(tree)) return output; for (TreeGrepMatch<T> match : matcher.getMatches()) { output.addAll(generateRelations(tree, match)); } return output; }
TreeRule { public List<List<T>> applyRule(Tree<T> tree) { List<List<T>> output = new ArrayList<>(); if (!matcher.matches(tree)) return output; for (TreeGrepMatch<T> match : matcher.getMatches()) { output.addAll(generateRelations(tree, match)); } return output; } }
TreeRule { public List<List<T>> applyRule(Tree<T> tree) { List<List<T>> output = new ArrayList<>(); if (!matcher.matches(tree)) return output; for (TreeGrepMatch<T> match : matcher.getMatches()) { output.addAll(generateRelations(tree, match)); } return output; } TreeRule(Tree<T> pattern); }
TreeRule { public List<List<T>> applyRule(Tree<T> tree) { List<List<T>> output = new ArrayList<>(); if (!matcher.matches(tree)) return output; for (TreeGrepMatch<T> match : matcher.getMatches()) { output.addAll(generateRelations(tree, match)); } return output; } TreeRule(Tree<T> pattern); void addSubstition(List<Pair<Integer, T>> substitution); void addIntroduction(List<Pair<Integer, T>> introduction); List<List<T>> applyRule(Tree<T> tree); TreeGrep<T> getMatcher(); @Override String toString(); }
TreeRule { public List<List<T>> applyRule(Tree<T> tree) { List<List<T>> output = new ArrayList<>(); if (!matcher.matches(tree)) return output; for (TreeGrepMatch<T> match : matcher.getMatches()) { output.addAll(generateRelations(tree, match)); } return output; } TreeRule(Tree<T> pattern); void addSubstition(List<Pair<Integer, T>> substitution); void addIntroduction(List<Pair<Integer, T>> introduction); List<List<T>> applyRule(Tree<T> tree); TreeGrep<T> getMatcher(); @Override String toString();  }