/** Same thing, but with compound unary transitions */ public void testCompoundUnaryTransitions() { for (String treeText : treeStrings) { Tree tree = convertTree(treeText); List<Transition> transitions = CreateTransitionSequence.createTransitionSequence(tree, true); State state = ShiftReduceParser.initialStateFromGoldTagTree(tree); for (Transition transition : transitions) { state = transition.apply(state); } assertEquals(tree, state.stack.peek()); } }
public void testSeparators() { Tree tree = convertTree(commaTreeString); List<Transition> transitions = CreateTransitionSequence.createTransitionSequence(tree, true); List<String> expectedTransitions = Arrays.asList( new String[] { "Shift", "Shift", "Shift", "Shift", "RightBinary(@ADJP)", "RightBinary(ADJP)", "Shift", "RightBinary(@NP)", "RightBinary(NP)", "CompoundUnary([ROOT, FRAG])", "Finalize", "Idle" }); assertEquals( expectedTransitions, CollectionUtils.transformAsList( transitions, new Function<Transition, String>() { public String apply(Transition t) { return t.toString(); } })); String expectedSeparators = "[{2=,}]"; State state = ShiftReduceParser.initialStateFromGoldTagTree(tree); assertEquals(1, state.separators.size()); assertEquals(2, state.separators.firstKey().intValue()); assertEquals(",", state.separators.get(2)); }