@Test public void testGetAlignmentSets() throws Exception { AMR amr = new AMR(); AMR.Node root = amr.addNode("r", "root"); AMR.Node child1 = amr.addNode("c1", "child1"); AMR.Node child2 = amr.addNode("c2", "child2"); AMR.Arc arc1 = amr.addArc(root, child1, "arc1"); AMR.Arc arc2 = amr.addArc(root, child2, "arc2"); child1.alignment = 0; root.alignment = 1; child2.alignment = 2; Map<Integer, Set<AMR.Node>> alignmentSets = ParserUtils.getAlignmentSets(amr); assertEquals(1, alignmentSets.get(0).size()); assertEquals(child1, alignmentSets.get(0).iterator().next()); assertEquals(1, alignmentSets.get(1).size()); assertEquals(root, alignmentSets.get(1).iterator().next()); assertEquals(1, alignmentSets.get(2).size()); assertEquals(child2, alignmentSets.get(2).iterator().next()); child2.alignment = 0; alignmentSets = ParserUtils.getAlignmentSets(amr); assertEquals(2, alignmentSets.get(0).size()); assertTrue(alignmentSets.get(0).contains(child1)); assertTrue(alignmentSets.get(0).contains(child2)); assertEquals(1, alignmentSets.get(1).size()); assertEquals(root, alignmentSets.get(1).iterator().next()); }
@Test public void testIsAlignmentChunkable() throws Exception { AMR amr = new AMR(); AMR.Node root = amr.addNode("r", "root"); AMR.Node child1 = amr.addNode("c1", "child1"); AMR.Node child2 = amr.addNode("c2", "child2"); AMR.Arc arc1 = amr.addArc(root, child1, "arc1"); AMR.Arc arc2 = amr.addArc(root, child2, "arc2"); child1.alignment = 0; root.alignment = 1; child2.alignment = 2; assertEquals(true, ParserUtils.isAlignmentChunkable(amr)); child2.alignment = 0; assertEquals(false, ParserUtils.isAlignmentChunkable(amr)); child1.alignment = 1; assertEquals(true, ParserUtils.isAlignmentChunkable(amr)); }
@Test public void testAlignmentChunksAndArcs() throws Exception { AMR amr = new AMR(); AMR.Node root = amr.addNode("r", "root"); AMR.Node child1 = amr.addNode("c1", "child1"); AMR.Node child2 = amr.addNode("c2", "child2"); AMR.Arc arc1 = amr.addArc(root, child1, "arc1"); AMR.Arc arc2 = amr.addArc(root, child2, "arc2"); amr.sourceText = new String[] {"he", "ran", "dog"}; child1.alignment = 0; root.alignment = 1; child2.alignment = 2; Pair<AMR[], List<ParserUtils.ChunkArc>> pair = ParserUtils.alignmentChunksAndArcs(amr); AMR[] chunks = pair.first; List<ParserUtils.ChunkArc> chunkArcs = pair.second; assertEquals(3, chunks.length); assertEquals(2, chunkArcs.size()); }