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

First usable version

parent e93a54a3
No related branches found
No related tags found
No related merge requests found
Pipeline #1051 passed
...@@ -39,5 +39,6 @@ ...@@ -39,5 +39,6 @@
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.3.1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.3.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.3.1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.3.1" level="project" />
<orderEntry type="library" name="Maven: info.debatty:java-aggregation:0.2" level="project" /> <orderEntry type="library" name="Maven: info.debatty:java-aggregation:0.2" level="project" />
<orderEntry type="library" name="Maven: com.owlike:genson:1.4" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -30,6 +30,11 @@ ...@@ -30,6 +30,11 @@
<artifactId>java-aggregation</artifactId> <artifactId>java-aggregation</artifactId>
<version>0.2</version> <version>0.2</version>
</dependency> </dependency>
<dependency>
<groupId>com.owlike</groupId>
<artifactId>genson</artifactId>
<version>1.4</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
This diff is collapsed.
This diff is collapsed.
package be.cylab.java.wowa.training; package be.cylab.java.wowa.training;
import java.util.ArrayList; import com.owlike.genson.GenericType;
import com.owlike.genson.Genson;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
...@@ -11,25 +16,34 @@ import java.util.logging.Logger; ...@@ -11,25 +16,34 @@ import java.util.logging.Logger;
*/ */
public class Example { public class Example {
public static void main(String[] args) { public static void main(String[] args) throws IOException {
Logger LOGGER = Logger.getLogger(Trainer.class.getName()); Logger LOGGER = Logger.getLogger(Trainer.class.getName());
LOGGER.setLevel(Level.INFO); LOGGER.setLevel(Level.INFO);
TrainerParameters parameters = new TrainerParameters(LOGGER, 200, 60, 10, TrainerParameters.SELECTION_METHOD_RWS, 100); TrainerParameters parameters = new TrainerParameters(LOGGER, 100, 60, 10, TrainerParameters.SELECTION_METHOD_RWS, 250);
Trainer trainer = new Trainer(parameters); Trainer trainer = new Trainer(parameters);
List<double[]> data = new ArrayList<>(); Genson genson = new Genson();
for (int i = 0; i < 1500; i++) {
double[] element = {Math.random(), Math.random(), Math.random()}; String dataJson = new String(Files.readAllBytes(Paths.get("/home/alex/Documents/java-wowa-training/ressources/webshell_data.json")));
data.add(element); List<double[]> data = genson.deserialize(dataJson, new GenericType<List<double[]>>(){});
} String expectedJson = new String(Files.readAllBytes(Paths.get("/home/alex/Documents/java-wowa-training/ressources/webshell_expected.json")));
double[] expected = new double[1500]; double[] expected = genson.deserialize(expectedJson, double[].class);
for (int j = 0; j < 1500; j++) { //String expectedJson = new String(Files.readAllBytes(Paths.get("/home/alex/Documents/wowa-training/tests/webshell_expected.json")));
expected[j] = Math.random(); //double[] expected = genson.deserialize(expectedJson, new GenericType<double[]>() {});
}
//String expectedJsonNew = genson.serialize(expected, new GenericType<double[]>(){});
//BufferedWriter writer = new BufferedWriter(new FileWriter("/home/alex/Documents/java-wowa-training/ressources/webshell_expected.json"));
//writer.write(expectedJson);
//writer.close();
SolutionDistance solution = trainer.run(data, expected); SolutionDistance solution = trainer.run(data, expected);
System.out.println(solution); System.out.println(solution);
} }
} }
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