Skip to content
Permalink
0d82ff1dc4
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
52 lines (42 sloc) 2.2 KB
package test.kb.howtokb.clustering;
import java.util.List;
import kb.howtokb.clustering.HeuristicTopDownClustering;
import kb.howtokb.clustering.basicobj.CSKSimpleCluster;
import kb.howtokb.clustering.basicobj.Instance;
import kb.howtokb.taskframe.WikiHowTaskFrame;
import kb.howtokb.tools.InformationExtraction;
public class HeuristicTopDownClusteringTest {
public static void main(String[] args) throws Exception {
long startTime = System.currentTimeMillis();
// Writer out = new BufferedWriter(new OutputStreamWriter(
// new FileOutputStream("/var/tmp/cxchu/clustering-result/act-frame-domain-15k-heuristic-results.txt"), "utf-8"));
// String input = "/var/tmp/cxchu/groundtruth-data/Old-Data/act-frame-sim.json";
// String input = "/var/tmp/cxchu/clustering-result/bottomup-results/0-1k/bottom-up-cluster-56.json";
String input = "howtokb-data/task-frame-before-clustering.json";
List<WikiHowTaskFrame> allframe = InformationExtraction.getAllFrame(input);
System.out.println("Initializing simple topdown clustering.....");
// InstanceInLeafSimpleStopping<ActivityFrame> stopper = new InstanceInLeafSimpleStopping<>(5);
HeuristicTopDownClustering cluster = new HeuristicTopDownClustering(allframe, false, 0.9, 5);
System.out.println("Done! Start clustering.......");
int k=2;
List<CSKSimpleCluster<WikiHowTaskFrame>> res = cluster.splitACluster(cluster.getInputCluster(), k);
System.out.println("Done! Results..............");
// out.write("Number of clusters: " + res.size() + "\n");
for (int i=0; i<res.size(); i++){
List<Instance<WikiHowTaskFrame>> frames = res.get(i).getClusterMembers();
for (int j=0; j<frames.size(); j++){
System.out.println(frames.get(j).getData());
// out.write(frames.get(j).getData() + "\n");
}
System.out.println(frames.size());
System.out.println("====================================");
// out.write("===========================\n");
}
System.out.println("Number of clusters: " + res.size());
long endTime = System.currentTimeMillis();
long totalTime = (endTime - startTime)/1000;
System.out.println("Running time: " + totalTime + "second(s)");
// out.write("Running time: " + totalTime + " minute(s)");
// out.close();
}
}