/** * Returns the size of the cluster calculated as the number of unique documents it * contains, including its subclusters. * * @return size of the cluster */ public int size() { return getAllDocuments().size(); }
/** * Returns all documents in this cluster ordered according to the provided comparator. * See {@link Document} for common comparators. */ public List<Document> getAllDocuments(Comparator<Document> comparator) { final List<Document> sortedDocuments = Lists.newArrayList(getAllDocuments()); Collections.sort(sortedDocuments, comparator); return sortedDocuments; }
int calculateH(Cluster cluster) { final Map<Object, Integer> documentCountByPartition = getDocumentCountByPartition(cluster .getAllDocuments()); final ArrayList<Integer> counts = Lists.newArrayList(); counts.addAll(documentCountByPartition.values()); return calculateH(counts); }
@SuppressWarnings("unchecked") double calculate(Cluster cluster, int partitionCount) { int clusterPartitionAssignments = 0; for (Document document : cluster.getAllDocuments()) { clusterPartitionAssignments += ((Collection<Object>) document .getField(Document.PARTITIONS)).size(); } final double worstCaseH = calculateWorstCaseH(clusterPartitionAssignments, partitionCount); if (worstCaseH == 0) { return 0; } else { return calculateH(cluster) / worstCaseH; } }
private void clustersToNamedList(List<Cluster> outputClusters, List parent, boolean outputSubClusters, int maxLabels) { for (Cluster outCluster : outputClusters) { NamedList cluster = new SimpleOrderedMap(); parent.add(cluster); List<String> labels = outCluster.getPhrases(); if (labels.size() > maxLabels) labels = labels.subList(0, maxLabels); cluster.add("labels", labels); List<Document> docs = outputSubClusters ? outCluster.getDocuments() : outCluster.getAllDocuments(); List docList = new ArrayList(); cluster.add("docs", docList); for (Document doc : docs) { docList.add(doc.getField("solrId")); } if (outputSubClusters) { List subclusters = new ArrayList(); cluster.add("clusters", subclusters); clustersToNamedList(outCluster.getSubclusters(), subclusters, outputSubClusters, maxLabels); } } }
final List<Document> clusterDocuments = cluster.getAllDocuments(); if (cluster.isOtherTopics() || clusterDocuments.size() == 0)
for (Object partition : partitions) final List<Document> clusterDocuments = cluster.getAllDocuments(); if (cluster.isOtherTopics() || clusterDocuments.size() == 0)
List<Document> docs = outputSubClusters ? outCluster.getDocuments() : outCluster.getAllDocuments(); List<Object> docList = new ArrayList<>(); cluster.add("docs", docList);
List<Document> docs = cluster.getAllDocuments(); int return_size=0; if (docs != null && docs.size() > 0) {