Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update
  • Loading branch information
cxchu committed Mar 21, 2017
1 parent 27470b6 commit b9e3764
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 68 deletions.
43 changes: 0 additions & 43 deletions pom.xml
Expand Up @@ -54,47 +54,4 @@
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>edu.washington.cs.knowitall.openie</groupId>
<artifactId>openie_2.10</artifactId>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp-models</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>niket.tool</groupId>
<artifactId>javatools</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>niket.tool</groupId>
<artifactId>postgresql</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>colt</groupId>
<artifactId>colt</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
</project>
@@ -1,52 +1,46 @@
package kb.howtokb.clustering;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.List;

import kb.howtokb.clustering.HeuristicBottomupClustering.ActivitySuperCluster;
import kb.howtokb.clustering.sim.Coefficient;
import kb.howtokb.taskframe.WikiHowTaskFrame;
import kb.howtokb.tools.InformationExtraction;

public class HeuristicBottomUpClusteringTest {
public static void main(String[] args) throws Exception {

long startTime = System.currentTimeMillis();


String activityTb = "resources/all-words-category.txt";
HeuristicBottomupClustering cluster = new HeuristicBottomupClustering(activityTb);

double threshold = Coefficient.VVNN_TRHES;
String model = "/var/tmp/cxchu/w2v-model/articles-word2vec-word-pos.model.txt";
String model = "articles-word2vec-word-pos.model.txt";
String allAct = "resources/all-strong-activities.txt";
SimplePruningSimilarity simFunc = new SimplePruningSimilarity(threshold, model, allAct);
List<ActivitySuperCluster> results = cluster.cluster(simFunc, Coefficient.VVNN_TRHES);
System.out.println("Number of clusters: " + results.size());
String output = "/var/tmp/cxchu/clustering-result/bottom-up-cluster-";
// String output = "/var/tmp/cxchu/clustering-result/bottom-up-cluster-";

String input = ""; //original data point file
List<WikiHowTaskFrame> allframe = InformationExtraction.getAllFrame(input);
// String input = "/var/tmp/cxchu/act-frame-test.json"; //original data point file
// List<WikiHowTaskFrame> allframe = InformationExtraction.getAllFrame(input);
int total = 0;
for (int i = 0; i < results.size(); i++) {
System.out.println("Cluster " + i + ": " + results.get(i).getSuperClusterMembers().size());
Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(output+i+".json"), "utf-8"));
List<Integer> actitiviesID =
results.get(i).getSuperClusterMembers();
for (int j=0; j<allframe.size(); j++){
if (actitiviesID.contains(allframe.get(j).getID())){
out.write(allframe.get(j).toJsonObject().toJSONString() + "\n");
allframe.remove(j);
j--;
total++;
}
}

out.close();
// Writer out = new BufferedWriter(new OutputStreamWriter(
// new FileOutputStream(output+i+".json"), "utf-8"));
// List<Integer> actitiviesID =
// results.get(i).getSuperClusterMembers();
// for (int j=0; j<allframe.size(); j++){
// if (actitiviesID.contains(allframe.get(j).getID())){
// out.write(allframe.get(j).toJsonObject().toJSONString() + "\n");
// allframe.remove(j);
// j--;
// total++;
// }
// }
//
// out.close();
}

long endTime = System.currentTimeMillis();
Expand Down

0 comments on commit b9e3764

Please sign in to comment.