@Test public void canConvertDependencies() throws UIMAException { String[] tags = {"DT", "VBZ", "DT", "NN", "."}; sentence.tags_$eq(Some.apply(tags)); Set<Object> roots = ImmutableSet.of(3); ImmutableList<Edge<String>> edges = ImmutableList.of( new Edge<>(3, 0, "nsubj"), new Edge<>(3, 1, "cop"), new Edge<>(3, 2, "det"), new Edge<>(3, 4, "punct")); DirectedGraph<String> deps = new DirectedGraph<>( JavaConversions.asScalaBuffer(edges).toList(), JavaConversions.asScalaSet(roots).toSet()); sentence.setDependencies(GraphMap.UNIVERSAL_ENHANCED(), deps); when(document.sentences()).thenReturn(new Sentence[] {sentence}); DocumentConverter converter = new DocumentConverter(jCas, document); converter.convert(); List<WordToken> tokens = ImmutableList.copyOf(JCasUtil.select(jCas, WordToken.class)); Collection<Dependency> actual = JCasUtil.select(jCas, Dependency.class); assertEquals(5, actual.size()); Iterator<Dependency> iterator = actual.iterator(); Dependency next = iterator.next(); assertEquals("nsubj", next.getDependencyType()); assertEquals(tokens.get(3), next.getGovernor()); assertEquals(tokens.get(0), next.getDependent()); next = iterator.next(); assertEquals("cop", next.getDependencyType()); assertEquals(tokens.get(3), next.getGovernor()); assertEquals(tokens.get(1), next.getDependent()); next = iterator.next(); assertEquals("det", next.getDependencyType()); assertEquals(tokens.get(3), next.getGovernor()); assertEquals(tokens.get(2), next.getDependent()); next = iterator.next(); assertEquals(MaltParser.ROOT, next.getDependencyType()); assertEquals(tokens.get(3), next.getGovernor()); assertEquals(tokens.get(3), next.getDependent()); next = iterator.next(); assertEquals("punct", next.getDependencyType()); assertEquals(tokens.get(3), next.getGovernor()); assertEquals(tokens.get(4), next.getDependent()); }
public void convert() { for (Sentence sentence : document.sentences()) { convert(sentence); } }
DocumentConverter { public void convert() { for (Sentence sentence : document.sentences()) { convert(sentence); } } }
DocumentConverter { public void convert() { for (Sentence sentence : document.sentences()) { convert(sentence); } } DocumentConverter(JCas jCas, Document document); }
DocumentConverter { public void convert() { for (Sentence sentence : document.sentences()) { convert(sentence); } } DocumentConverter(JCas jCas, Document document); void convert(); }
DocumentConverter { public void convert() { for (Sentence sentence : document.sentences()) { convert(sentence); } } DocumentConverter(JCas jCas, Document document); void convert();  }