@Test public void canCreateSentenceWithEntities() throws UIMAException { JCas jCas = JCasFactory.createJCas(); addWordTokens(jCas); Organisation organisation = Annotations.createOrganisation(jCas, 5, 7, "test"); organisation.setIsNormalised(true); Annotations.createPerson(jCas, 10, 18, "sentence"); SentenceFactory factory = new SentenceFactory(jCas); Sentence sentence = factory.create().get(0); assertEquals( ImmutableSet.of( MISSING_VALUE, Organisation.class.getSimpleName(), MISSING_VALUE, Person.class.getSimpleName(), MISSING_VALUE), ImmutableSet.copyOf(sentence.entities().get())); assertEquals( ImmutableSet.of(MISSING_VALUE, "test", MISSING_VALUE, MISSING_VALUE, MISSING_VALUE), ImmutableSet.copyOf(sentence.norms().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();  }