Update merging

This commit is contained in:
Louis Calas
2019-10-03 15:08:36 +02:00
parent 7bbe8284cd
commit 7f5c60caad
20 changed files with 97 additions and 47 deletions

View File

@@ -41,7 +41,7 @@ public class Exec implements Callable <Void> {
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 <Void> {
.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);
}

View File

@@ -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 <Void> {
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 !

View File

@@ -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<String,String> etudiants;
int numLength;
String path = "../export";
public GenerateCSV(HashMap<String,String> 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());
}
}
}

View File

@@ -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<BufferedImage> 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<String> files = pdfAnalyzer.listAllFiles(pdfFilesDirectory, ".pdf");
for (String fname : files) {
@@ -56,9 +57,9 @@ public class GestionnaireCopies {
}
public Map<String,String> createHashMapforCSV(){
public HashMap<String,String> createHashMapforCSV(){
Map<String,String> temp = new HashMap<>();
HashMap<String,String> temp = new HashMap<>();
for(Copie c : listeCopie)
{
temp.put(c.getBase().gethMapImgs().get("NumEtu").getDescription(), c.getBase().gethMapImgs().get("Note").getDescription());

View File

@@ -1,7 +1,5 @@
package ocr;
import java.awt.image.BufferedImage;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

View File

@@ -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();
}