@Test public void canCreateSentenceWithPhraseChunks() throws UIMAException { JCas jCas = JCasFactory.createJCas(); addWordTokens(jCas); String chunk = "CHUNK"; PhraseChunk c1 = new PhraseChunk(jCas); c1.setBegin(0); c1.setEnd(9); c1.setChunkType(chunk); c1.addToIndexes(); SentenceFactory factory = new SentenceFactory(jCas); Sentence sentence = factory.create().get(0); assertEquals( ImmutableSet.of(chunk, chunk, chunk, MISSING_VALUE, MISSING_VALUE, MISSING_VALUE), ImmutableSet.copyOf(sentence.chunks().get())); }
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();  }