diff --git a/NGCC/Tess4J/eng.traineddata b/NGCC/Tess4J/eng.traineddata new file mode 100644 index 0000000..561883f Binary files /dev/null and b/NGCC/Tess4J/eng.traineddata differ diff --git a/NGCC/Tess4J/test/net/sourceforge/tess4j/Word.java b/NGCC/Tess4J/test/net/sourceforge/tess4j/Word.java deleted file mode 100644 index 585f0b4..0000000 --- a/NGCC/Tess4J/test/net/sourceforge/tess4j/Word.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.sourceforge.tess4j; - -import java.awt.Rectangle; - -/** - * Encapsulates Tesseract results. - */ -class Word { - - private final String text; - private final float confidence; - private final Rectangle rect; - - public Word(String text, float confidence, Rectangle rect) { - this.text = text; - this.confidence = confidence; - this.rect = rect; - } - - /** - * @return the text - */ - public String getText() { - return text; - } - - /** - * @return the confidence - */ - public float getConfidence() { - return confidence; - } - - /** - * @return the bounding box - */ - public Rectangle getRect() { - return rect; - } - - @Override - public String toString() { - return String.format("%s\t[Confidence: %f Bounding box: %d %d %d %d]", text, confidence, rect.x, rect.y, rect.width, rect.height); - } -} diff --git a/NGCC/pdf b/NGCC/pdf index eec84a3..b247134 100644 --- a/NGCC/pdf +++ b/NGCC/pdf @@ -1 +1,7 @@ Student number;Grade +211052130 +;4 + +11052130 +;4 + diff --git a/NGCC/resources/log4j2.properties b/NGCC/resources/log4j2.properties index a751a36..78f1983 100644 --- a/NGCC/resources/log4j2.properties +++ b/NGCC/resources/log4j2.properties @@ -55,6 +55,12 @@ logger.d.appenderRefs = console logger.d.appenderRef.console.ref = STDOUT logger.d.appenderRef.file.ref = LOGFILE +logger.console.name = commands +logger.console.level = fatal +logger.console.additivity = false +logger.console.appenderRefs = console +logger.console.appenderRef.console.ref = STDOUT +logger.console.appenderRef.file.ref = LOGFILE logger.console.name = log4j logger.console.level = warn diff --git a/NGCC/src/commands/Read.java b/NGCC/src/commands/Read.java index 75e184c..bc45c11 100644 --- a/NGCC/src/commands/Read.java +++ b/NGCC/src/commands/Read.java @@ -9,8 +9,10 @@ import java.io.File; import java.io.PrintStream; import java.util.concurrent.Callable; +import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.core.config.Configurator; import config.Config; import csv.GenerateCSV; @@ -35,7 +37,7 @@ import ocr.GestionnaireCopies; public class Read implements Callable { - private static Logger logger; + private static Logger logger = LogManager.getLogger(Read.class); @Spec Model.CommandSpec spec; @@ -47,7 +49,7 @@ public class Read implements Callable { int step; @Option(names= {"-v"}, arity = "0..*", order = 3, defaultValue = "1", description ="verbose mode") - int vb_level; + public int vb_level; @Option(names= {"-d"}, arity = "1", order = 4, defaultValue = "copies", description ="directory") String directory_name; @@ -76,19 +78,19 @@ public class Read implements Callable { // Niveau de debug selon verbosite if (vb_level >= 0 && vb_level <=2) { - logger = LogManager.getFormatterLogger("fatalLogger"); + Configurator.setLevel("commands", Level.FATAL); } else if (vb_level >= 3 && vb_level <=4) { - logger = LogManager.getFormatterLogger("errorLogger"); + Configurator.setLevel("commands", Level.ERROR); } else if (vb_level >= 5 && vb_level <=6) { - logger = LogManager.getFormatterLogger("warnLogger"); + Configurator.setLevel("commands", Level.WARN); } else if (vb_level >= 7 && vb_level <=8) { - logger = LogManager.getFormatterLogger("infoLogger"); + Configurator.setLevel("commands", Level.INFO); } else { - logger = LogManager.getFormatterLogger("debugLogger"); + Configurator.setLevel("commands", Level.DEBUG); } // Help genere de la commande @@ -141,11 +143,11 @@ public class Read implements Callable { String filePath = new File("").getAbsolutePath(); - GestionnaireCopies ocr = new GestionnaireCopies("..\\"+directory_name+"\\"); + GestionnaireCopies ocr = new GestionnaireCopies("../"+directory_name); // Instantie l'ocr - GenerateCSV csv = new GenerateCSV(ocr.createHashMapforCSV(),config.getParam().get("Code"), result_name, logger); + GenerateCSV csv = new GenerateCSV(ocr.createHashMapforCSV(),config.getParam().get("Code"), result_name); csv.createFile(); //Génère le fichier csv à partir de la HMap retournée par l'OCR diff --git a/NGCC/src/csv/GenerateCSV.java b/NGCC/src/csv/GenerateCSV.java index ab6979b..b3632cd 100644 --- a/NGCC/src/csv/GenerateCSV.java +++ b/NGCC/src/csv/GenerateCSV.java @@ -6,6 +6,7 @@ import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; +import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class GenerateCSV { @@ -13,13 +14,12 @@ public class GenerateCSV { Map etudiants; int numLength; String path = "../export"; - Logger logger; + Logger logger = LogManager.getLogger(GenerateCSV.class); - public GenerateCSV(Map map, String length, String pth, Logger lg) { + public GenerateCSV(Map map, String length, String pth) { this.etudiants = map; this.numLength = Integer.parseInt(length); this.path = path + "/" + pth; - this.logger = lg; } // Teste validité du numero etudiant (selon param de la config passé : @@ -50,7 +50,7 @@ public class GenerateCSV { } public void createFile() { - try (PrintWriter writer = new PrintWriter(new File("pdf"))) { + try (PrintWriter writer = new PrintWriter(new File(this.path))) { logger.info("Creating csv file"); StringBuilder sb = new StringBuilder(); @@ -68,9 +68,12 @@ public class GenerateCSV { // Si etudiant HashMap est null, pas ecrit if (etud != null) { - if (this.isValid(etud)) { + //if (this.isValid(etud)) { writer.write(etud + ";" + etudiants.get(etud) + System.getProperty("line.separator")); - } + //} +// else { +// logger.debug("Invalid not added to csv"); +// } } else { diff --git a/NGCC/tests/log4j/TestLog4j.java b/NGCC/tests/log4j/TestLog4j.java index da8f510..3adf3bf 100644 --- a/NGCC/tests/log4j/TestLog4j.java +++ b/NGCC/tests/log4j/TestLog4j.java @@ -2,18 +2,23 @@ package log4j; import static org.junit.jupiter.api.Assertions.*; - - +import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.core.config.Configurator; import org.junit.jupiter.api.Test; class TestLog4j { - private static Logger logger = LogManager.getFormatterLogger("log4j"); + private static Logger logger = LogManager.getLogger(TestLog4j.class); public static void main(String[] args) { + int v = 9; + + if (v > 8) { + Configurator.setLevel("log4j", Level.DEBUG); + } logger.debug("msg de debogage"); logger.info("msg d'information"); @@ -23,27 +28,5 @@ class TestLog4j { } - /* Idee verbosité - * - * Logger logger; - * - * if (v >= 0 && v <= 2) { - * logger = LogManager.getLogger(LogManager.getLogger("fatalLogger")); - * } - * else if (v >= 3 && v <= 4) { - * logger = LogManager.getLogger(LogManager.getLogger("errorLogger")); - * } - * else if (v >= 5 && v <= 6) { - * logger = LogManager.getLogger(LogManager.getLogger("warnLogger")); - * } - * else if (v >= 7 && v <= 8) { - * logger = LogManager.getLogger(LogManager.getLogger("infoLogger")); - * } - * else { - * logger = LogManager.getLogger(LogManager.getLogger("debugLogger")); - * } - * - * -> On met quand même logger.warn(...) et il apparaitra ou non selon le logger - */ } diff --git a/grades.csv b/grades.csv index bb9fdb5..e69de29 100644 --- a/grades.csv +++ b/grades.csv @@ -1,4 +0,0 @@ -Student number,Grade -1234; 6.0 -96543; 16.8 -12345678910; 20.0