Commit 7f545c98 authored by Tien's avatar Tien

Add option to save detail log

parent e342b3bb
...@@ -20,6 +20,7 @@ import Checker.Classifier; ...@@ -20,6 +20,7 @@ import Checker.Classifier;
import Checker.DistantCalculator; import Checker.DistantCalculator;
import Checker.Indexer; import Checker.Indexer;
import Checker.Reader; import Checker.Reader;
import Logger.Log;
import TextExtractor.pdfextractor; import TextExtractor.pdfextractor;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
...@@ -39,14 +40,15 @@ import java.util.HashMap; ...@@ -39,14 +40,15 @@ import java.util.HashMap;
*/ */
public class ScigenChecker_Local { public class ScigenChecker_Local {
private String loglocation; // private String loglocation;
private String detailloglocation; // private String detailloglocation;
private String testpath; private String testpath;
private String logtime; //private String logtime;
private HashMap<String, HashMap<String, Integer>> samples = new HashMap<String, HashMap<String, Integer>>(); private HashMap<String, HashMap<String, Integer>> samples = new HashMap<String, HashMap<String, Integer>>();
private HashMap<String, HashMap<String, Integer>> tests = new HashMap<String, HashMap<String, Integer>>(); private HashMap<String, HashMap<String, Integer>> tests = new HashMap<String, HashMap<String, Integer>>();
private String SamplesFolder; private String SamplesFolder;
private HashMap<String, HashMap<String, Double>> distant = new HashMap<String, HashMap<String, Double>>(); private HashMap<String, HashMap<String, Double>> distant = new HashMap<String, HashMap<String, Double>>();
private Boolean savedetaillog = false;
private void readconfig() throws FileNotFoundException, IOException { private void readconfig() throws FileNotFoundException, IOException {
File conf = new File("config.txt"); File conf = new File("config.txt");
...@@ -61,11 +63,11 @@ public class ScigenChecker_Local { ...@@ -61,11 +63,11 @@ public class ScigenChecker_Local {
} }
if (b[0].equals("Default_log_folder")) { if (b[0].equals("Default_log_folder")) {
loglocation = b[1]; Log.loglocation = b[1];
// System.out.println(loglocation); // System.out.println(loglocation);
} }
if (b[0].equals("Default_detail_log_folder")) { if (b[0].equals("Default_detail_log_folder")) {
detailloglocation = b[1]; Log.detailloglocation = b[1];
//System.out.println(detailloglocation); //System.out.println(detailloglocation);
} }
} }
...@@ -77,7 +79,7 @@ public class ScigenChecker_Local { ...@@ -77,7 +79,7 @@ public class ScigenChecker_Local {
if (testpath != null) { if (testpath != null) {
DateFormat dateFormat = new SimpleDateFormat("HH:mm dd.MM.yyyy"); DateFormat dateFormat = new SimpleDateFormat("HH:mm dd.MM.yyyy");
Date date = new Date(); Date date = new Date();
logtime = dateFormat.format(date); Log.logtime = dateFormat.format(date);
try { try {
Reader reader = new Reader(); Reader reader = new Reader();
...@@ -95,66 +97,29 @@ public class ScigenChecker_Local { ...@@ -95,66 +97,29 @@ public class ScigenChecker_Local {
Classifier cl = new Classifier(); Classifier cl = new Classifier();
String conclusion = cl.classify(distant); String conclusion = cl.classify(distant);
System.out.println(conclusion); System.out.println(conclusion);
savedetaillog(); Log log = new Log();
savelog(conclusion); log.savelog(conclusion);
} else { if (savedetaillog) {
System.out.println("can not read path to test folder"); log.savedetaillog(distant);
}
}
private void savedetaillog() {
File distantout = new File(detailloglocation + logtime + ".xls");
//File distantout = new File(testpath+"/alldistant.xls");
PrintWriter out;
try {
out = new PrintWriter(distantout);
for (String key : distant.keySet()) {
for (String key2 : distant.get(key).keySet()) {
out.println(key + "\t" + key2 + "\t"
+ distant.get(key).get(key2));
}
} }
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void savelog(String conclusion) {
File distantout ;
if (!loglocation.equals("logs/")) {
distantout = new File(loglocation);
} else { } else {
distantout = new File(loglocation+ logtime + ".xls"); System.out.println("can not read path to test folder");
}
PrintWriter out;
try {
out = new PrintWriter(distantout);
out.write(conclusion);
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
} }
public void readargs(String[] args) { public void readargs(String[] args) {
for (int i = 0; i < args.length; i += 2) { for (int i = 0; i < args.length; i += 1) {
// System.out.println(args[i]); // System.out.println(args[i]);
if (args[i].equals("-l")) { if (args[i].equals("-l")) {
loglocation = args[i + 1]; Log.loglocation = args[i + 1];
} }
if (args[i].equals("-c")) { if (args[i].equals("-c")) {
testpath = args[i + 1]; testpath = args[i + 1];
} }
if (args[i].equals("-d")) {
savedetaillog = true;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment