@Test public void canCreateSentenceWithDependencies() throws UIMAException { JCas jCas = JCasFactory.createJCas(); addWordTokens(jCas); Annotations.createDependency(jCas, wt4, wt4, MaltParser.ROOT); Annotations.createDependency(jCas, wt4, wt1, "nsubj"); Annotations.createDependency(jCas, wt4, wt2, "cop"); Annotations.createDependency(jCas, wt4, wt3, "det"); Annotations.createDependency(jCas, wt4, wt5, "punct"); SentenceFactory factory = new SentenceFactory(jCas); Sentence sentence = factory.create().get(0); Option<DirectedGraph<String>> dependencies = sentence.dependencies(); assertTrue(dependencies.isDefined()); GraphMap graphs = sentence.graphs(); assertNotNull(graphs); Option<DirectedGraph<String>> graph = sentence.dependencies(); assertTrue(graph.isDefined()); DirectedGraph<String> directedGraph = graph.get(); assertTrue(directedGraph.hasEdge(3, 3, "root")); assertTrue(directedGraph.hasEdge(3, 0, "nsubj")); assertTrue(directedGraph.hasEdge(3, 1, "cop")); assertTrue(directedGraph.hasEdge(3, 2, "det")); assertTrue(directedGraph.hasEdge(3, 4, "punct")); }
public List<OdinSentence> create() { List<Entry<Sentence, List<WordToken>>> entrySet = indexWords.entrySet().stream() .sorted(Comparator.comparing(e -> e.getKey().getBegin())) .collect(toList()); List<OdinSentence> sentences = new ArrayList<>(); for (Entry<Sentence, List<WordToken>> e : entrySet) { sentences.add(create(sentences.size(), e.getKey(), e.getValue())); } return sentences; }
SentenceFactory { public List<OdinSentence> create() { List<Entry<Sentence, List<WordToken>>> entrySet = indexWords.entrySet().stream() .sorted(Comparator.comparing(e -> e.getKey().getBegin())) .collect(toList()); List<OdinSentence> sentences = new ArrayList<>(); for (Entry<Sentence, List<WordToken>> e : entrySet) { sentences.add(create(sentences.size(), e.getKey(), e.getValue())); } return sentences; } }
SentenceFactory { public List<OdinSentence> create() { List<Entry<Sentence, List<WordToken>>> entrySet = indexWords.entrySet().stream() .sorted(Comparator.comparing(e -> e.getKey().getBegin())) .collect(toList()); List<OdinSentence> sentences = new ArrayList<>(); for (Entry<Sentence, List<WordToken>> e : entrySet) { sentences.add(create(sentences.size(), e.getKey(), e.getValue())); } return sentences; } SentenceFactory(JCas jCas); protected  SentenceFactory(
      Map<Sentence, List<WordToken>> indexWords,
      Map<WordToken, List<Entity>> indexEntities,
      Map<WordToken, List<PhraseChunk>> indexChunks,
      Map<Sentence, List<Dependency>> indexDependency); }
SentenceFactory { public List<OdinSentence> create() { List<Entry<Sentence, List<WordToken>>> entrySet = indexWords.entrySet().stream() .sorted(Comparator.comparing(e -> e.getKey().getBegin())) .collect(toList()); List<OdinSentence> sentences = new ArrayList<>(); for (Entry<Sentence, List<WordToken>> e : entrySet) { sentences.add(create(sentences.size(), e.getKey(), e.getValue())); } return sentences; } SentenceFactory(JCas jCas); protected  SentenceFactory(
      Map<Sentence, List<WordToken>> indexWords,
      Map<WordToken, List<Entity>> indexEntities,
      Map<WordToken, List<PhraseChunk>> indexChunks,
      Map<Sentence, List<Dependency>> indexDependency); List<OdinSentence> create(); }
SentenceFactory { public List<OdinSentence> create() { List<Entry<Sentence, List<WordToken>>> entrySet = indexWords.entrySet().stream() .sorted(Comparator.comparing(e -> e.getKey().getBegin())) .collect(toList()); List<OdinSentence> sentences = new ArrayList<>(); for (Entry<Sentence, List<WordToken>> e : entrySet) { sentences.add(create(sentences.size(), e.getKey(), e.getValue())); } return sentences; } SentenceFactory(JCas jCas); protected  SentenceFactory(
      Map<Sentence, List<WordToken>> indexWords,
      Map<WordToken, List<Entity>> indexEntities,
      Map<WordToken, List<PhraseChunk>> indexChunks,
      Map<Sentence, List<Dependency>> indexDependency); List<OdinSentence> create();  }