@Test void shouldCusterHeuristically() { final AtomicLong atomicLong = new AtomicLong(); final RefineClusterImpl<Long, Person> refineCluster = RefineClusterImpl.<Long, Person>builder() .classifier(new CustomClassifier()) .clusterIdGenerator(personList -> atomicLong.getAndIncrement()) .maxSmallClusterSize(4) .build(); final Cluster<Long, Person> personCluster = new Cluster<>(0L, List.of( new Person("1", "Joanna"), new Person("2", "Joanna"), new Person("3", "Joanna"), new Person("4", "Joanna"), new Person("5", "Joanna") )); final Stream<Cluster<Long, Person>> actual = refineCluster.refine(Stream.of(personCluster), Stream.empty()); assertThat(actual) .hasSize(1) .allSatisfy(cluster -> assertThat(cluster).isEqualTo(personCluster)); }
public Stream<Cluster<C, T>> refine(final Stream<? extends Cluster<C, T>> clusters, final @NonNull Stream<ClassifiedCandidate<T>> knownClassifications) { final Map<T, List<ClassifiedCandidate<T>>> relevantClassificationIndex = this.getRelevantClassificationIndex(knownClassifications); return clusters.flatMap(cluster -> this.refineCluster(cluster, this.getRelevantClassifications(cluster, relevantClassificationIndex))); }
RefineClusterImpl implements RefineCluster<C, T> { public Stream<Cluster<C, T>> refine(final Stream<? extends Cluster<C, T>> clusters, final @NonNull Stream<ClassifiedCandidate<T>> knownClassifications) { final Map<T, List<ClassifiedCandidate<T>>> relevantClassificationIndex = this.getRelevantClassificationIndex(knownClassifications); return clusters.flatMap(cluster -> this.refineCluster(cluster, this.getRelevantClassifications(cluster, relevantClassificationIndex))); } }
RefineClusterImpl implements RefineCluster<C, T> { public Stream<Cluster<C, T>> refine(final Stream<? extends Cluster<C, T>> clusters, final @NonNull Stream<ClassifiedCandidate<T>> knownClassifications) { final Map<T, List<ClassifiedCandidate<T>>> relevantClassificationIndex = this.getRelevantClassificationIndex(knownClassifications); return clusters.flatMap(cluster -> this.refineCluster(cluster, this.getRelevantClassifications(cluster, relevantClassificationIndex))); }  }
RefineClusterImpl implements RefineCluster<C, T> { public Stream<Cluster<C, T>> refine(final Stream<? extends Cluster<C, T>> clusters, final @NonNull Stream<ClassifiedCandidate<T>> knownClassifications) { final Map<T, List<ClassifiedCandidate<T>>> relevantClassificationIndex = this.getRelevantClassificationIndex(knownClassifications); return clusters.flatMap(cluster -> this.refineCluster(cluster, this.getRelevantClassifications(cluster, relevantClassificationIndex))); }  Stream<Cluster<C, T>> refine(final Stream<? extends Cluster<C, T>> clusters,
            final @NonNull Stream<ClassifiedCandidate<T>> knownClassifications); }
RefineClusterImpl implements RefineCluster<C, T> { public Stream<Cluster<C, T>> refine(final Stream<? extends Cluster<C, T>> clusters, final @NonNull Stream<ClassifiedCandidate<T>> knownClassifications) { final Map<T, List<ClassifiedCandidate<T>>> relevantClassificationIndex = this.getRelevantClassificationIndex(knownClassifications); return clusters.flatMap(cluster -> this.refineCluster(cluster, this.getRelevantClassifications(cluster, relevantClassificationIndex))); }  Stream<Cluster<C, T>> refine(final Stream<? extends Cluster<C, T>> clusters,
            final @NonNull Stream<ClassifiedCandidate<T>> knownClassifications);  }