@Test public void testReplaceWithCoreferent() { final Collection<Entity> entities = Arrays.asList(he); final Map<ReferenceTarget, Entity> referentMap = new HashMap<>(); referentMap.put(chrisRT, chris); final Set<Entity> coreferents = ReferentUtils.replaceWithCoreferent(entities, referentMap); assertEquals(chris, coreferents.iterator().next()); }
public static Set<Entity> replaceWithCoreferent( Collection<Entity> entities, Map<ReferenceTarget, Entity> referentMap) { final Set<Entity> set = new HashSet<>(entities.size()); for (final Entity t : entities) { if (t.getReferent() == null) { set.add(t); } else { final Entity entity = referentMap.get(t.getReferent()); if (entity != null) { set.add(entity); } else { set.add(t); } } } return set; }
ReferentUtils { public static Set<Entity> replaceWithCoreferent( Collection<Entity> entities, Map<ReferenceTarget, Entity> referentMap) { final Set<Entity> set = new HashSet<>(entities.size()); for (final Entity t : entities) { if (t.getReferent() == null) { set.add(t); } else { final Entity entity = referentMap.get(t.getReferent()); if (entity != null) { set.add(entity); } else { set.add(t); } } } return set; } }
ReferentUtils { public static Set<Entity> replaceWithCoreferent( Collection<Entity> entities, Map<ReferenceTarget, Entity> referentMap) { final Set<Entity> set = new HashSet<>(entities.size()); for (final Entity t : entities) { if (t.getReferent() == null) { set.add(t); } else { final Entity entity = referentMap.get(t.getReferent()); if (entity != null) { set.add(entity); } else { set.add(t); } } } return set; } private  ReferentUtils(); }
ReferentUtils { public static Set<Entity> replaceWithCoreferent( Collection<Entity> entities, Map<ReferenceTarget, Entity> referentMap) { final Set<Entity> set = new HashSet<>(entities.size()); for (final Entity t : entities) { if (t.getReferent() == null) { set.add(t); } else { final Entity entity = referentMap.get(t.getReferent()); if (entity != null) { set.add(entity); } else { set.add(t); } } } return set; } private  ReferentUtils(); static Multimap<ReferenceTarget, T> createReferentMap(
      final JCas jCas, final Class<T> clazz); static Multimap<ReferenceTarget, T> createReferentMap(
      final JCas jCas, final Class<T> clazz, final boolean filterEmptyReference); static Multimap<ReferenceTarget, T> createReferentMap(
      final JCas jCas, final Collection<T> mentions, final boolean filterEmptyReference); static Map<ReferenceTarget, T> filterToSingle(
      Multimap<ReferenceTarget, T> referentMap, Function<Collection<T>, T> convert); static List<Base> getAllEntityOrReferentToEntity(
      JCas jCas, Map<ReferenceTarget, Entity> referentMap); @SuppressWarnings("unlikely-arg-type") static List<Base> getAllAndReferents(
      JCas jCas, Class<T> clazz, Map<ReferenceTarget, T> referentMap); static Stream<Base> streamReferent(
      JCas jCas, Map<ReferenceTarget, T> referentMap); static T getLongestSingle(Collection<T> list); static T singleViaCompare(Collection<T> list, Comparator<T> compare); static Set<Entity> replaceWithCoreferent(
      Collection<Entity> entities, Map<ReferenceTarget, Entity> referentMap); }
ReferentUtils { public static Set<Entity> replaceWithCoreferent( Collection<Entity> entities, Map<ReferenceTarget, Entity> referentMap) { final Set<Entity> set = new HashSet<>(entities.size()); for (final Entity t : entities) { if (t.getReferent() == null) { set.add(t); } else { final Entity entity = referentMap.get(t.getReferent()); if (entity != null) { set.add(entity); } else { set.add(t); } } } return set; } private  ReferentUtils(); static Multimap<ReferenceTarget, T> createReferentMap(
      final JCas jCas, final Class<T> clazz); static Multimap<ReferenceTarget, T> createReferentMap(
      final JCas jCas, final Class<T> clazz, final boolean filterEmptyReference); static Multimap<ReferenceTarget, T> createReferentMap(
      final JCas jCas, final Collection<T> mentions, final boolean filterEmptyReference); static Map<ReferenceTarget, T> filterToSingle(
      Multimap<ReferenceTarget, T> referentMap, Function<Collection<T>, T> convert); static List<Base> getAllEntityOrReferentToEntity(
      JCas jCas, Map<ReferenceTarget, Entity> referentMap); @SuppressWarnings("unlikely-arg-type") static List<Base> getAllAndReferents(
      JCas jCas, Class<T> clazz, Map<ReferenceTarget, T> referentMap); static Stream<Base> streamReferent(
      JCas jCas, Map<ReferenceTarget, T> referentMap); static T getLongestSingle(Collection<T> list); static T singleViaCompare(Collection<T> list, Comparator<T> compare); static Set<Entity> replaceWithCoreferent(
      Collection<Entity> entities, Map<ReferenceTarget, Entity> referentMap); static final Predicate<? super Base> NOT_ENTITY_OR_REFERENT; static final Predicate<? super Base> ENTITY_OR_REFERENT; }