-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patharff.txt
More file actions
141 lines (109 loc) · 4.85 KB
/
arff.txt
File metadata and controls
141 lines (109 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package webfeaturingaco;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
*
* @author JP
*/
public class produceARFF {
private static PrintStream s_outs;
static Connection ACOfeature_selection;
static PreparedStatement query, query1, query2, query3, query4, query5;
static ResultSet query_rs, query_rs2, query_rs3, query_rs4, query_rs5;
static int query_rs1;
public produceARFF() {
ACOfeature_selection = null;
query = null;
query_rs = null;
query1 = null;
query2 = null;
query_rs2 = null;
s_outs = null;
}
public void generateARFF() {
try {
//database conectivity
String url1 = "jdbc:mysql://localhost:3306/ACO1";
Class.forName("com.mysql.jdbc.Driver").newInstance();
ACOfeature_selection = DriverManager.getConnection(url1, "root", "root");
//WebFeaturingACOView.writeToTextArea("connection established succesfully");
query = ACOfeature_selection.prepareStatement("select * from webpagestested where test=1");
query_rs = query.executeQuery();
while (query_rs.next()) {
String t_name = query_rs.getString(3);
System.out.println(t_name);
if (s_outs == null) {
try {
s_outs = new PrintStream(new FileOutputStream("E:\\ACO_workspace\\Results\\ARFF\\" + t_name + ".arff"));
} catch (Exception ex) {
}
}
try {
query1 = ACOfeature_selection.prepareStatement("update webpagestested set test = 2 where tablename='" + t_name + "'");
query_rs1 = query1.executeUpdate();
} catch (Exception ex) {
}
try {
query4 = ACOfeature_selection.prepareStatement("select MAX(DISTINCT iteration) from ofeature_" + t_name);
query_rs4 = query4.executeQuery();
String rs_iteration = null;
String data = "";
while (query_rs4.next()) {
//System.out.println(query_rs4.getString(1));
rs_iteration = query_rs4.getString(1);
}
s_outs.println("@RELATION aco");
try {
String wg = "0";
query3 = ACOfeature_selection.prepareStatement("select feature from trainingdataset");
query_rs3 = query3.executeQuery();
while (query_rs3.next()) {
s_outs.println("@ATTRIBUTE " + query_rs3.getString(1) + " NUMERIC");
}
s_outs.println("@ATTRIBUTE class {course,student,faculty,others}");
s_outs.println("@DATA");
query2 = ACOfeature_selection.prepareStatement("select feature from trainingdataset");
query_rs2 = query2.executeQuery();
while (query_rs2.next()) {
try {
query5 = ACOfeature_selection.prepareStatement("select feature,nrweight from ofeature_" + t_name + " where iteration=" + rs_iteration);
query_rs5 = query5.executeQuery();
while (query_rs5.next()) {
if (query_rs2.getString(1).equals(query_rs5.getString(1))) {
wg = null;
wg = query_rs5.getString(2);
System.out.println(wg+ query_rs5.getString(2));
}
}
data = data + wg;
data = data + ",";
wg="0";
} catch (Exception ex) {
}
}
} catch (Exception ex) {
}
data = data + "?";
s_outs.println(data);
} catch (Exception ex) {
}
s_outs=null;
}
if (!query_rs.next()) {
System.out.println("No more ARFF to be generated");
}
} catch (Exception ex) {
}
}
public static void main(String[] args) {
new produceARFF().generateARFF();
}
}