@Test public void ensureSenteceOrderingCorrect() throws UIMAException { JCas jCas = JCasFactory.createJCas(); jCas.setDocumentText("This is sentence one. This is sentence two. This is sentence three."); Annotations.createWordTokens(jCas); List<Sentence> sentences = Annotations.createSentences(jCas); OdinSentence sentence1 = mock(OdinSentence.class, "s1"); OdinSentence sentence2 = mock(OdinSentence.class, "s2"); OdinSentence sentence3 = mock(OdinSentence.class, "s3"); when(sentenceFactory.create()).thenReturn(ImmutableList.of(sentence1, sentence2, sentence3)); when(sentence1.getBaleenSentence()).thenReturn(sentences.get(0)); when(sentence2.getBaleenSentence()).thenReturn(sentences.get(1)); when(sentence3.getBaleenSentence()).thenReturn(sentences.get(2)); DocumentFactory documentFactory = new DocumentFactory(jCas, sentenceFactory); OdinDocument document = documentFactory.create(); OdinSentence[] odinSentences = (OdinSentence[]) document.sentences(); assertEquals(3, odinSentences.length); assertEquals(sentences.get(0), odinSentences[0].getBaleenSentence()); assertEquals(sentences.get(1), odinSentences[1].getBaleenSentence()); assertEquals(sentences.get(2), odinSentences[2].getBaleenSentence()); assertEquals(document.findSentence(sentences.get(0)), odinSentences[0]); assertEquals(document.findSentence(sentences.get(1)), odinSentences[1]); assertEquals(document.findSentence(sentences.get(2)), odinSentences[2]); }
public OdinDocument create() { OdinDocument document = new OdinDocument(sentenceFactory.create()); document.text_$eq(Some.apply(jCas.getDocumentText())); int chainId = 0; List<CorefMention> mentions = new ArrayList<>(); for (Entry<ReferenceTarget, Collection<Entity>> coref : referentMap.asMap().entrySet()) { for (Entity entity : coref.getValue()) { Collection<Sentence> collection = entityIndex.get(entity); if (!collection.isEmpty()) { OdinSentence sentence = document.findSentence(collection.iterator().next()); mentions.add(sentence.corefMention(entity, chainId)); } } chainId++; } CorefChains chains = CorefChains.apply(JavaConversions.iterableAsScalaIterable(mentions)); document.coreferenceChains_$eq(Option.apply(chains)); return document; }
DocumentFactory { public OdinDocument create() { OdinDocument document = new OdinDocument(sentenceFactory.create()); document.text_$eq(Some.apply(jCas.getDocumentText())); int chainId = 0; List<CorefMention> mentions = new ArrayList<>(); for (Entry<ReferenceTarget, Collection<Entity>> coref : referentMap.asMap().entrySet()) { for (Entity entity : coref.getValue()) { Collection<Sentence> collection = entityIndex.get(entity); if (!collection.isEmpty()) { OdinSentence sentence = document.findSentence(collection.iterator().next()); mentions.add(sentence.corefMention(entity, chainId)); } } chainId++; } CorefChains chains = CorefChains.apply(JavaConversions.iterableAsScalaIterable(mentions)); document.coreferenceChains_$eq(Option.apply(chains)); return document; } }
DocumentFactory { public OdinDocument create() { OdinDocument document = new OdinDocument(sentenceFactory.create()); document.text_$eq(Some.apply(jCas.getDocumentText())); int chainId = 0; List<CorefMention> mentions = new ArrayList<>(); for (Entry<ReferenceTarget, Collection<Entity>> coref : referentMap.asMap().entrySet()) { for (Entity entity : coref.getValue()) { Collection<Sentence> collection = entityIndex.get(entity); if (!collection.isEmpty()) { OdinSentence sentence = document.findSentence(collection.iterator().next()); mentions.add(sentence.corefMention(entity, chainId)); } } chainId++; } CorefChains chains = CorefChains.apply(JavaConversions.iterableAsScalaIterable(mentions)); document.coreferenceChains_$eq(Option.apply(chains)); return document; } DocumentFactory(JCas jCas);  DocumentFactory(JCas jCas, SentenceFactory sentenceFactory);  DocumentFactory(
      JCas jCas,
      Map<Entity, List<Sentence>> entityIndex,
      Multimap<ReferenceTarget, Entity> referentMap,
      SentenceFactory sentenceFactory); }
DocumentFactory { public OdinDocument create() { OdinDocument document = new OdinDocument(sentenceFactory.create()); document.text_$eq(Some.apply(jCas.getDocumentText())); int chainId = 0; List<CorefMention> mentions = new ArrayList<>(); for (Entry<ReferenceTarget, Collection<Entity>> coref : referentMap.asMap().entrySet()) { for (Entity entity : coref.getValue()) { Collection<Sentence> collection = entityIndex.get(entity); if (!collection.isEmpty()) { OdinSentence sentence = document.findSentence(collection.iterator().next()); mentions.add(sentence.corefMention(entity, chainId)); } } chainId++; } CorefChains chains = CorefChains.apply(JavaConversions.iterableAsScalaIterable(mentions)); document.coreferenceChains_$eq(Option.apply(chains)); return document; } DocumentFactory(JCas jCas);  DocumentFactory(JCas jCas, SentenceFactory sentenceFactory);  DocumentFactory(
      JCas jCas,
      Map<Entity, List<Sentence>> entityIndex,
      Multimap<ReferenceTarget, Entity> referentMap,
      SentenceFactory sentenceFactory); OdinDocument create(); }
DocumentFactory { public OdinDocument create() { OdinDocument document = new OdinDocument(sentenceFactory.create()); document.text_$eq(Some.apply(jCas.getDocumentText())); int chainId = 0; List<CorefMention> mentions = new ArrayList<>(); for (Entry<ReferenceTarget, Collection<Entity>> coref : referentMap.asMap().entrySet()) { for (Entity entity : coref.getValue()) { Collection<Sentence> collection = entityIndex.get(entity); if (!collection.isEmpty()) { OdinSentence sentence = document.findSentence(collection.iterator().next()); mentions.add(sentence.corefMention(entity, chainId)); } } chainId++; } CorefChains chains = CorefChains.apply(JavaConversions.iterableAsScalaIterable(mentions)); document.coreferenceChains_$eq(Option.apply(chains)); return document; } DocumentFactory(JCas jCas);  DocumentFactory(JCas jCas, SentenceFactory sentenceFactory);  DocumentFactory(
      JCas jCas,
      Map<Entity, List<Sentence>> entityIndex,
      Multimap<ReferenceTarget, Entity> referentMap,
      SentenceFactory sentenceFactory); OdinDocument create();  }