Bug fixes
This commit is contained in:
parent
925d7d8f6f
commit
540b9ca512
BIN
NGCC/Tess4J/eng.traineddata
Normal file
BIN
NGCC/Tess4J/eng.traineddata
Normal file
Binary file not shown.
@ -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);
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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 <Void> {
|
||||
|
||||
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 <Void> {
|
||||
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 <Void> {
|
||||
// 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 <Void> {
|
||||
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
|
||||
|
||||
|
@ -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<String, String> etudiants;
|
||||
int numLength;
|
||||
String path = "../export";
|
||||
Logger logger;
|
||||
Logger logger = LogManager.getLogger(GenerateCSV.class);
|
||||
|
||||
public GenerateCSV(Map<String, String> map, String length, String pth, Logger lg) {
|
||||
public GenerateCSV(Map<String, String> 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 {
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
Student number,Grade
|
||||
1234; 6.0
|
||||
96543; 16.8
|
||||
12345678910; 20.0
|
|
Loading…
x
Reference in New Issue
Block a user