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
42 lines (32 sloc) 1.57 KB
package test.kb.howtokb.clustering;
import java.util.List;
import kb.howtokb.clustering.HeuristicTopDownClusteringDynamicSparse;
import kb.howtokb.clustering.basicobj.CSKSimpleCluster;
import kb.howtokb.clustering.basicobj.Instance;
import kb.howtokb.taskframe.WikiHowTaskFrame;
import kb.howtokb.tools.InformationExtraction;
public class HeuristicTopDownClusteringDynamicSparseTest {
public static void main(String[] args) throws Exception {
long startTime = System.currentTimeMillis();
String input = "howtokb-data/task-frame-before-clustering.json";
List<WikiHowTaskFrame> allframe = InformationExtraction.getAllFrame(input);
System.out.println("Initializing simple topdown clustering.....");
HeuristicTopDownClusteringDynamicSparse cluster = new HeuristicTopDownClusteringDynamicSparse(allframe, false, 0.9, 5, 0.5);
System.out.println("Done! Start clustering.......");
int k=2;
List<CSKSimpleCluster<WikiHowTaskFrame>> res = cluster.splitACluster(cluster.getInputCluster(), k);
System.out.println("Done! Results..............");
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());
}
System.out.println(frames.size());
System.out.println("====================================");
}
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)");
}
}