/** * Creates the referent map - map of referent target to entities. * * @param <T> the generic type * @param jCas the j cas * @param clazz the clazz * @return the multimap */ public static <T extends Base> Multimap<ReferenceTarget, T> createReferentMap( final JCas jCas, final Class<T> clazz) { return createReferentMap(jCas, clazz, true); }
/** * Creates the referent map - map of referent target to entities. * * @param <T> the generic type * @param jCas the j cas * @param clazz the clazz * @return the multimap */ public static <T extends Base> Multimap<ReferenceTarget, T> createReferentMap( final JCas jCas, final Class<T> clazz) { return createReferentMap(jCas, clazz, true); }
/** * Creates the referent map - map of referent target to entities. * * @param <T> the generic type * @param jCas the j cas * @param clazz the clazz * @param filterEmptyReference true to filter empty references, false to add a stand in reference * @return the multimap */ public static <T extends Base> Multimap<ReferenceTarget, T> createReferentMap( final JCas jCas, final Class<T> clazz, final boolean filterEmptyReference) { final Collection<T> potentialReferences = JCasUtil.select(jCas, clazz); return createReferentMap(jCas, potentialReferences, filterEmptyReference); }
/** * Creates the referent map - map of referent target to entities. * * @param <T> the generic type * @param jCas the j cas * @param clazz the clazz * @param filterEmptyReference true to filter empty references, false to add a stand in reference * @return the multimap */ public static <T extends Base> Multimap<ReferenceTarget, T> createReferentMap( final JCas jCas, final Class<T> clazz, final boolean filterEmptyReference) { final Collection<T> potentialReferences = JCasUtil.select(jCas, clazz); return createReferentMap(jCas, potentialReferences, filterEmptyReference); }
/** * Construct the document factory for the given jCas and {@link SentenceFactory} * * @param jCas to base the document on * @param sentenceFactory to use */ public DocumentFactory(JCas jCas, SentenceFactory sentenceFactory) { this( jCas, JCasUtil.indexCovering(jCas, Entity.class, Sentence.class), ReferentUtils.createReferentMap(jCas, Entity.class), sentenceFactory); }
/** * Construct the document factory for the given jCas and {@link SentenceFactory} * * @param jCas to base the document on * @param sentenceFactory to use */ public DocumentFactory(JCas jCas, SentenceFactory sentenceFactory) { this( jCas, JCasUtil.indexCovering(jCas, Entity.class, Sentence.class), ReferentUtils.createReferentMap(jCas, Entity.class), sentenceFactory); }
@Override public <T extends Entity> Set<EntityInformation<T>> getEntityInformation( JCas jCas, Class<T> clazz) { Multimap<ReferenceTarget, T> map = ReferentUtils.createReferentMap(jCas, clazz); Map<T, Collection<Sentence>> index = JCasUtil.indexCovering(jCas, clazz, Sentence.class); Set<EntityInformation<T>> infos = new HashSet<>(); for (Map.Entry<ReferenceTarget, Collection<T>> entry : map.asMap().entrySet()) { Collection<Sentence> sentences = entry.getValue().stream().flatMap(m -> index.get(m).stream()).collect(Collectors.toSet()); infos.add(new EntityInformation<T>(entry.getKey(), entry.getValue(), sentences)); } return infos; } }
@Override public <T extends Entity> Set<EntityInformation<T>> getEntityInformation( JCas jCas, Class<T> clazz) { Multimap<ReferenceTarget, T> map = ReferentUtils.createReferentMap(jCas, clazz); Map<T, Collection<Sentence>> index = JCasUtil.indexCovering(jCas, clazz, Sentence.class); Set<EntityInformation<T>> infos = new HashSet<>(); for (Map.Entry<ReferenceTarget, Collection<T>> entry : map.asMap().entrySet()) { Collection<Sentence> sentences = entry.getValue().stream().flatMap(m -> index.get(m).stream()).collect(Collectors.toSet()); infos.add(new EntityInformation<T>(entry.getKey(), entry.getValue(), sentences)); } return infos; } }
@Override public <T extends Entity> Set<EntityInformation<T>> getEntityInformation( JCas jCas, Class<T> clazz) { Multimap<ReferenceTarget, T> map = ReferentUtils.createReferentMap(jCas, clazz); Map<T, Collection<Sentence>> index = JCasUtil.indexCovering(jCas, clazz, Sentence.class); Map<T, Collection<WordToken>> tokens = JCasUtil.indexCovered(jCas, clazz, WordToken.class);
@Override public <T extends Entity> Set<EntityInformation<T>> getEntityInformation( JCas jCas, Class<T> clazz) { Multimap<ReferenceTarget, T> map = ReferentUtils.createReferentMap(jCas, clazz); Map<T, Collection<Sentence>> index = JCasUtil.indexCovering(jCas, clazz, Sentence.class); Map<T, Collection<WordToken>> tokens = JCasUtil.indexCovered(jCas, clazz, WordToken.class);
ReferentUtils.createReferentMap(jCas, Entity.class, false);
@Test public void testCreateReferentMap() { final Multimap<ReferenceTarget, Entity> map = ReferentUtils.createReferentMap(jCas, Entity.class); assertEquals(2, map.get(chrisRT).size()); assertEquals(2, map.get(londonRT).size()); }
ReferentUtils.createReferentMap(jCas, Entity.class, true) .asMap() .forEach(
ReferentUtils.createReferentMap(jCas, annotations, false);
ReferentUtils.createReferentMap(jCas, annotations, false);
bigBen.addToIndexes(); referentMap = ReferentUtils.createReferentMap(jCas, Entity.class);
ReferentUtils.createReferentMap(jCas, Entity.class, false); targets .entries()
ReferentUtils.createReferentMap(jCas, Entity.class, false); targets .entries()