diff --git a/NGCC/jar/fontbox-2.0.16.jar b/NGCC/jar/fontbox-2.0.16.jar old mode 100644 new mode 100755 diff --git a/NGCC/jar/pdfbox-2.0.16.jar b/NGCC/jar/pdfbox-2.0.16.jar old mode 100644 new mode 100755 diff --git a/NGCC/jar/pdfbox-app-2.0.16.jar b/NGCC/jar/pdfbox-app-2.0.16.jar new file mode 100755 index 0000000..319d975 Binary files /dev/null and b/NGCC/jar/pdfbox-app-2.0.16.jar differ diff --git a/NGCC/jar/pdfbox-debugger-2.0.16.jar b/NGCC/jar/pdfbox-debugger-2.0.16.jar old mode 100644 new mode 100755 diff --git a/NGCC/jar/pdfbox-tools-2.0.16.jar b/NGCC/jar/pdfbox-tools-2.0.16.jar old mode 100644 new mode 100755 diff --git a/NGCC/jar/preflight-2.0.16.jar b/NGCC/jar/preflight-2.0.16.jar new file mode 100755 index 0000000..42acc21 Binary files /dev/null and b/NGCC/jar/preflight-2.0.16.jar differ diff --git a/NGCC/jar/preflight-app-2.0.16.jar b/NGCC/jar/preflight-app-2.0.16.jar new file mode 100755 index 0000000..bdc7eac Binary files /dev/null and b/NGCC/jar/preflight-app-2.0.16.jar differ diff --git a/NGCC/jar/xmpbox-2.0.16.jar b/NGCC/jar/xmpbox-2.0.16.jar new file mode 100755 index 0000000..e37902b Binary files /dev/null and b/NGCC/jar/xmpbox-2.0.16.jar differ diff --git a/NGCC/resources/log4j2.properties b/NGCC/resources/log4j2.properties deleted file mode 100644 index ff7573d..0000000 --- a/NGCC/resources/log4j2.properties +++ /dev/null @@ -1,24 +0,0 @@ -name=PropertiesConfig -property.filename = logs -appenders = console, file - -appender.console.type = Console -appender.console.name = STDOUT -appender.console.layout.type = PatternLayout -appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n - -appender.file.type = File -appender.file.name = LOGFILE -appender.file.fileName=${filename}/propertieslogs.log -appender.file.layout.type=PatternLayout -appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n - -loggers=file -logger.file.name = NGCC -logger.file.level = debug -logger.file.appenderRefs = file -logger.file.appenderRef.file.ref = LOGFILE - -rootLogger.level = debug -rootLogger.appenderRefs = stdout -rootLogger.appenderRef.stdout.ref = STDOUT \ No newline at end of file diff --git a/NGCC/src/Exec.java b/NGCC/src/Exec.java index 2ba7802..4b51d5d 100644 --- a/NGCC/src/Exec.java +++ b/NGCC/src/Exec.java @@ -41,7 +41,7 @@ public class Exec implements Callable { public static void main(String[] args) throws InterruptedException { // Système de subcommand semblable à celui de git permettant d'appeler les classes relatives - + String[] t = {"-r","-d","pdf"}; CommandLine cmd = new CommandLine (new Exec()) .addSubcommand("-r", new Read(System.out)) // nom commande, objet commande .addSubcommand("-b", new Build(System.out)) @@ -51,7 +51,7 @@ public class Exec implements Callable { .addSubcommand("-e", new Evaluate(System.out)) .addSubcommand("help", new HelpCommand()); // Aide générée automatiquement par l'API - cmd.execute(args); + cmd.execute(t); } diff --git a/NGCC/src/commands/Read.java b/NGCC/src/commands/Read.java index 38d89c2..460d5ce 100644 --- a/NGCC/src/commands/Read.java +++ b/NGCC/src/commands/Read.java @@ -1,6 +1,7 @@ package commands; import picocli.CommandLine; + import picocli.CommandLine.*; import progressbar.ProgressBar; @@ -8,7 +9,8 @@ import java.io.PrintStream; import java.util.concurrent.Callable; import config.Config; -import ocr_orm.ControleurOCR; +import csv.GenerateCSV; +import ocr.GestionnaireCopies; @@ -105,13 +107,16 @@ public class Read implements Callable { Config config = new Config(source_path); //Initialise le fichier de configuration selon le path donné - ControleurOCR ocr = new ControleurOCR(); //Initialise le controle de l'OCR + config.readConfig(); - ocr.setConfig(config); //Configure l'OCR en fonction du fichier de configuration initialisé + GestionnaireCopies ocr = new GestionnaireCopies(directory_name); + GenerateCSV csv = new GenerateCSV(ocr.createHashMapforCSV(),config.getParam().get("Code"), result_name); - GenerateCSV.createFile(ocr.getNumNote(directory_name),result_name); //Génère le fichier csv à partir de la HMap retournée par l'OCR + //ocr.setConfig(config); //Configure l'OCR en fonction du fichier de configuration initialisé + + csv.createFile(); //Génère le fichier csv à partir de la HMap retournée par l'OCR //Done ! diff --git a/NGCC/src/csv/GenerateCSV.java b/NGCC/src/csv/GenerateCSV.java new file mode 100644 index 0000000..54d1fb0 --- /dev/null +++ b/NGCC/src/csv/GenerateCSV.java @@ -0,0 +1,70 @@ +package csv; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.util.HashMap; + +public class GenerateCSV { + + HashMap etudiants; + int numLength; + String path = "../export"; + + public GenerateCSV(HashMap map, String s, String p) { + this.etudiants = map; + this.numLength = Integer.parseInt(s); + this.path = path+"/"+p; + } + +// public boolean isValid(String s) { +// int i = 0; +// if (s.length() == this.numLength) { +// while (i < s.length()) +// { +// if (s.charAt(i) != '0' && s.charAt(i) == '1' || s.charAt(i) == '2' || s.charAt(i) == '3' +// || s.charAt(i) == '4' || s.charAt(i) == '5' || s.charAt(i) == '6' || s.charAt(i) == '7' +// || s.charAt(i) == '8' || s.charAt(i) == '9') +// { +// return true; +// +// } else { +// return false; +// break; +// } +// i++; +// } +// } +// +// return true; +// } + + + + + + public void createFile() { + try (PrintWriter writer = new PrintWriter(new File(this.path))) { + + StringBuilder sb = new StringBuilder(); + sb.append("Student number"); + sb.append(';'); + sb.append("Grade"); + sb.append(System.getProperty("line.separator")); + + writer.write(sb.toString()); + + for (String etud : this.etudiants.keySet()) { + + writer.write(etud+";"+etudiants.get(etud)+System.getProperty("line.separator")); + + } + System.out.println("Create File Done!"); + + } catch (FileNotFoundException e) { + System.err.println(e.getMessage()); + } + } + + +} diff --git a/NGCC/src/ocr/GestionnaireCopies.java b/NGCC/src/ocr/GestionnaireCopies.java index 6971731..07fa53b 100644 --- a/NGCC/src/ocr/GestionnaireCopies.java +++ b/NGCC/src/ocr/GestionnaireCopies.java @@ -1,6 +1,7 @@ package ocr; import java.awt.image.BufferedImage; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -37,7 +38,7 @@ public class GestionnaireCopies { List images = new ArrayList<>(); // stockera les images (resultat) // CONVERT PAGES TO IMAGES try { - String pdfFilesDirectory = "C:\\Users\\ph807242\\eclipse-workspace\\PT\\pdf\\"; + String pdfFilesDirectory = "/Users/louis/Desktop/IUT_S3/PT/pt-s3t-g4/pdf"; // nom du fichier pdf à ouvrir (TODO: changer le chemin) List files = pdfAnalyzer.listAllFiles(pdfFilesDirectory, ".pdf"); for (String fname : files) { @@ -56,9 +57,9 @@ public class GestionnaireCopies { } - public Map createHashMapforCSV(){ + public HashMap createHashMapforCSV(){ - Map temp = new HashMap<>(); + HashMap temp = new HashMap<>(); for(Copie c : listeCopie) { temp.put(c.getBase().gethMapImgs().get("NumEtu").getDescription(), c.getBase().gethMapImgs().get("Note").getDescription()); diff --git a/NGCC/src/ocr/OCR.java b/NGCC/src/ocr/OCR.java index 96cf264..b679fd2 100644 --- a/NGCC/src/ocr/OCR.java +++ b/NGCC/src/ocr/OCR.java @@ -1,7 +1,5 @@ package ocr; import java.awt.image.BufferedImage; - - import net.sourceforge.tess4j.Tesseract; import net.sourceforge.tess4j.TesseractException; diff --git a/NGCC/src/ocr/PdfToImage.java b/NGCC/src/ocr/PdfToImage.java index b80295b..92c34c0 100644 --- a/NGCC/src/ocr/PdfToImage.java +++ b/NGCC/src/ocr/PdfToImage.java @@ -79,7 +79,7 @@ public class PdfToImage { images.add(bim); System.out.println("Ajout n°" + pageCounter); } - // document.close(); + document.close(); } catch (IOException ioe) { ioe.printStackTrace(); } diff --git a/NGCC/tests/config/TestQuestion.java b/NGCC/tests/config/TestQuestion.java index c9a1eea..b04e11f 100644 --- a/NGCC/tests/config/TestQuestion.java +++ b/NGCC/tests/config/TestQuestion.java @@ -20,15 +20,15 @@ public class TestQuestion { } @Test void testAddReponse() { - Reponse r1=new Reponse("+ Au collège des ninjas",true); - Question q=new Question("Selon la serie diffusée en 1991 sur TF1, où le petit Nicolas doit il travailler et s'appliquer ?",false); - q.addReponse(r1.getIntitulé()); - assertEquals("Au collège des ninjas",q.getReponses().get(0).getIntitulé()); - Reponse r2=new Reponse("- A l'académie des ninjas",false); - q.addReponse(r2.getIntitulé()); - assertEquals("A l'académie des ninjas",q.getReponses().get(1).getIntitulé()); + Reponse r1=new Reponse("+ Au coll�ge des ninjas",true); + Question q=new Question("Selon la serie diffus�e en 1991 sur TF1, o� le petit Nicolas doit il travailler et s'appliquer ?",false); + q.addReponse(r1.getIntitule()); + assertEquals("Au coll�ge des ninjas",q.getReponses().get(0).getIntitule()); + Reponse r2=new Reponse("- A l'acad�mie des ninjas",false); + q.addReponse(r2.getIntitule()); + assertEquals("A l'acad�mie des ninjas",q.getReponses().get(1).getIntitule()); q.addReponse("Suite de la question"); - assertEquals("Selon la serie diffusée en 1991 sur TF1, où le petit Nicolas doit il travailler et s'appliquer ?\nSuite de la question",q.getTitre()); + assertEquals("Selon la serie diffus�e en 1991 sur TF1, o� le petit Nicolas doit il travailler et s'appliquer ?\nSuite de la question",q.getTitre()); } diff --git a/NGCC/tests/config/TestReponse.java b/NGCC/tests/config/TestReponse.java index 3ec8768..f6e2370 100644 --- a/NGCC/tests/config/TestReponse.java +++ b/NGCC/tests/config/TestReponse.java @@ -7,8 +7,8 @@ import org.junit.jupiter.api.Test; public class TestReponse { @Test void testReponse() { - Reponse r=new Reponse("Je suis la réponse",true); - assertEquals("Je suis la réponse",r.getIntitulé()); + Reponse r=new Reponse("Je suis la r�ponse",true); + assertEquals("Je suis la r�ponse",r.getIntitule()); assertEquals(true,r.isJuste()); } diff --git a/NGCC/tests/log4j/TestLog4j.java b/NGCC/tests/log4j/TestLog4j.java index bd1410a..28581fc 100644 --- a/NGCC/tests/log4j/TestLog4j.java +++ b/NGCC/tests/log4j/TestLog4j.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; class TestLog4j { - private static Logger logger = LogManager.getLogger(); + private static Logger logger = LogManager.getLogger(LogManager.getLogger("ngccLog")); public static void main(String[] args) { diff --git a/pdf/testPDFMarks copie.pdf b/pdf/testPDFMarks copie.pdf new file mode 100644 index 0000000..4e1d787 Binary files /dev/null and b/pdf/testPDFMarks copie.pdf differ diff --git a/pdf/testPDFMarks.pdf b/pdf/testPDFMarks.pdf new file mode 100644 index 0000000..4e1d787 Binary files /dev/null and b/pdf/testPDFMarks.pdf differ