Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update code, changing directory.
  • Loading branch information
cxchu committed Oct 26, 2021
1 parent 28d71ad commit 0d82ff1
Show file tree
Hide file tree
Showing 70 changed files with 53 additions and 34 deletions.
4 changes: 4 additions & 0 deletions .settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="11"/>
</faceted-project>
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -88,6 +88,12 @@
<artifactId>javatools</artifactId>
<version>1.0.0</version>
</dependency>

<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.34.0</version>
</dependency>

</dependencies>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -17,10 +17,11 @@ public class SQLiteJDBCConnector {
public static boolean check = false;

public static String db = "wikihowDB";

public static ResultSet q(String sql) throws SQLException, ClassNotFoundException, IOException {
try{
if (check == false){
System.out.println("Initializing db ...");
createDB();
System.out.println("Initializing db successfully!");
}
Expand All @@ -42,19 +43,24 @@ public static ResultSet q(String sql) throws SQLException, ClassNotFoundExceptio
+ "Trying to automatically resolve...");

// returning empty result set for problematic query
return q("SELECT NULL LIMIT 0;");
// return q("SELECT NULL LIMIT 0;");
return null;
}
}
}

public static void createDB() throws SQLException, ClassNotFoundException, IOException {
try {

Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:" + db);

st = c.createStatement();
String sql = "CREATE TABLE IF NOT EXISTS frameidtostrongactsurface " + "(ID INT PRIMARY KEY NOT NULL,"
+ " task TEXT NOT NULL);";
st.executeUpdate(sql);


//
// sql = "DROP TABLE categoryjson";
// st.executeUpdate(sql);
Expand All @@ -65,20 +71,20 @@ public static void createDB() throws SQLException, ClassNotFoundException, IOExc
//System.out.println("Test");


ResultSet rs = st.executeQuery("select task from frameidtostrongactsurface where id=1;");
if (!rs.next()){
String input = "/var/tmp/cxchu/clustering-result/for-database/frame-id-to-strong-surface";
System.out.println("Updating data into table 'frameidtostrongactsurface'......");
update(st, "frameidtostrongactsurface", input);
}


rs = st.executeQuery("select json from categoryjson where id=1;");
if (!rs.next()){
String input = "/var/tmp/cxchu/wikihow-id-category.json";
System.out.println("Updating data into table 'category'.....");
update(st, "categoryjson", input);
}
// ResultSet rs = st.executeQuery("select task from frameidtostrongactsurface where id=1;");
// if (!rs.next()){
// String input = "/var/tmp/cxchu/clustering-result/for-database/frame-id-to-strong-surface";
// System.out.println("Updating data into table 'frameidtostrongactsurface'......");
// update(st, "frameidtostrongactsurface", input);
// }
//
//
// rs = st.executeQuery("select json from categoryjson where id=1;");
// if (!rs.next()){
// String input = "/var/tmp/cxchu/wikihow-id-category.json";
// System.out.println("Updating data into table 'category'.....");
// update(st, "categoryjson", input);
// }

check = true;
} catch (SQLException e) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
package kb.howtokb;
package test.kb.howtokb;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
Expand All @@ -14,12 +14,12 @@

public class TaskFrameReaderTest {
public static void main(String[] args) throws ClassNotFoundException, IOException, ParseException {
String input = "/var/tmp/cxchu/data-wordnet/act-frame.json";
String input = "howtokb-data/task-frame-gold-corpus.json";

ArrayList<WikiHowTaskFrame> allframe = TaskFrameReader.extractWikiHowTaskFrameFromJSONFile(input);

Writer textout = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("/var/tmp/cxchu/data-wordnet/act-frame-wikihow-task.json"), "utf-8"));
new FileOutputStream("howtokb-data/task-frame-output-test.json"), "utf-8"));

for (WikiHowTaskFrame f: allframe){

Expand Down
@@ -1,4 +1,4 @@
package kb.howtokb;
package test.kb.howtokb;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
Expand All @@ -24,14 +24,14 @@ public static void main(String[] args) throws ClassNotFoundException, IOExceptio
TextToWikiHowTaskFrame extract = new TextToWikiHowTaskFrame();
// Extract all question
System.out.println("Reading json data file.....");
String input = "/var/tmp/cxchu/data-for-test-code/articles_test.json";
String input = "howtokb-data/wikihow-data-all.json";
ArrayList<Question> allQuestions = WikiHowArticleReader.WikiHowArticleReaderFromJSONFile(input);
int frames = 0;
try {
Writer textout = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("/var/tmp/cxchu/data-for-test-code/act-frame.json"), "utf-8"));
new FileOutputStream("howtokb-data/task-frame-extracted.json"), "utf-8"));
Writer idtextout = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("/var/tmp/cxchu/data-for-test-code/id-act-frame.json"), "utf-8"));
new FileOutputStream("howtokb-data/id-task-frame-extracted.json"), "utf-8"));

int i = 1;

Expand Down
@@ -1,17 +1,16 @@
package kb.howtokb;
package test.kb.howtokb;

import java.io.IOException;
import java.util.ArrayList;

import org.json.simple.parser.ParseException;

import kb.howtokb.reader.WikiHowArticleReader;
import kb.howtokb.taskframe.extractor.TextToWikiHowTaskFrame;
import kb.howtokb.wkhobject.Question;

public class WikiHowArticleReaderTest {
public static void main(String[] args) throws ClassNotFoundException, IOException, ParseException {
String input = "/var/tmp/cxchu/articles_test.json";
String input = "howtokb-data/wikihow-data-all.json";
ArrayList<Question> allques = WikiHowArticleReader.WikiHowArticleReaderFromJSONFile(input);

int i=0;
Expand Down
@@ -1,12 +1,14 @@
package kb.howtokb.clustering;
package test.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;
import kb.howtokb.clustering.HeuristicBottomupClustering.ActivitySuperCluster;
import kb.howtokb.clustering.SimplePruningSimilarity;
import kb.howtokb.clustering.sim.Coefficient;
import kb.howtokb.taskframe.WikiHowTaskFrame;
import kb.howtokb.tools.InformationExtraction;
Expand All @@ -26,9 +28,9 @@ public static void main(String[] args) throws Exception {
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-wikihow-task/bottom-up-cluster-";
String output = "howtokb-data/cluster-results/bottom-up-cluster-";

String input = "/var/tmp/cxchu/data-server/For-Database/act-frame-wikihow-task.json"; //original data point file
String input = "howtokb-data/task-frame-before-clustering.json"; //original data point file
List<WikiHowTaskFrame> allframe = InformationExtraction.getAllFrame(input);
int total = 0;
for (int i = 0; i < results.size(); i++) {
Expand Down
@@ -1,7 +1,8 @@
package kb.howtokb.clustering;
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;
Expand All @@ -11,7 +12,7 @@ public class HeuristicTopDownClusteringDynamicSparseTest {
public static void main(String[] args) throws Exception {

long startTime = System.currentTimeMillis();
String input = "/var/tmp/cxchu/groundtruth-data/Old-Data/test.json";
String input = "howtokb-data/task-frame-before-clustering.json";

List<WikiHowTaskFrame> allframe = InformationExtraction.getAllFrame(input);

Expand Down
@@ -1,7 +1,8 @@
package kb.howtokb.clustering;
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;
Expand All @@ -16,7 +17,7 @@ public static void main(String[] args) throws Exception {
// 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 = "/var/tmp/cxchu/groundtruth-data/cate-domain.json";
String input = "howtokb-data/task-frame-before-clustering.json";
List<WikiHowTaskFrame> allframe = InformationExtraction.getAllFrame(input);

System.out.println("Initializing simple topdown clustering.....");
Expand Down
@@ -1,4 +1,4 @@
package kb.howtokb.jdbc;
package test.kb.howtokb.jdbc;

import java.io.IOException;
import java.sql.ResultSet;
Expand Down

0 comments on commit 0d82ff1

Please sign in to comment.