Skip to content
Snippets Groups Projects
Commit 75280f8e authored by a.croix's avatar a.croix
Browse files

Remove class used to convert data from array to List

parent 1d6457cd
No related branches found
No related tags found
No related merge requests found
Pipeline #1687 failed
package be.cylab.java.wowa.training;
import com.owlike.genson.GenericType;
import com.owlike.genson.Genson;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
/**
* Class to convert. Tmp
*/
public final class Convert {
private Convert() {
}
/**
* Main.
*
* @param args
*/
public static void main(final String[] args) {
String data_json = null;
String expected_json = null;
try {
data_json = new String(Files.readAllBytes(Paths.get(
"./ressources/webshell_data.json")),
StandardCharsets.UTF_8);
expected_json = new String(Files.readAllBytes(Paths.get(
"./ressources/webshell_expected.json")),
StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
Genson genson = new Genson();
List<double[]> data = genson.deserialize(data_json,
new GenericType<List<double[]>>() {
});
List<List<Double>> data_list = new ArrayList<>();
for (int i = 0; i < data.size(); i++) {
List<Double> vector_list = new ArrayList<>();
double[] vector = new double[data.get(i).length];
for (double el : vector) {
vector_list.add(el);
}
data_list.add(vector_list);
}
double[] expected = genson.deserialize(expected_json, double[].class);
List<Double> expected_list = new ArrayList<>();
for (double el : expected) {
expected_list.add(el);
}
String data_final = genson.serialize(data_list);
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(
"./ressources/webshell_data_list.json"));
writer.write(data_final);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
String expected_final = genson.serialize(expected_list);
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(
"./ressources/webshell_expected_list.json"));
writer.write(expected_final);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
......@@ -65,8 +65,8 @@ public final class Example {
long start_time = System.currentTimeMillis();
AbstractSolution solution = trainer.run(
"./ressources/webshell_data.json",
"./ressources/webshell_expected.json");
"./ressources/webshell_data_list.json",
"./ressources/webshell_expected_list.json");
System.out.println(solution);
long end_time = System.currentTimeMillis();
logger.log(Level.INFO, "Execution time : "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment