public Progress(int size, Program p) { this.program = p; this.size = size; pos = 0; program.print(progress_string, null); }
public Progress(long size,Program p) { this.program=p; this.size = size; pos = 0; program.print(progress_string, null); }
public final void set(long count) { long new_pos = (count*70 / size); while (pos < new_pos) { program.print("#", null); pos++; } }
public void addError(String errorMsg) { errorVector.add("[" + currentSubmissionName + "]\n" + errorMsg); print(errorMsg, null); }
public Submission(String name, File dir, Program p, Language language) { this.language = language; this.program = p; this.dir = dir; this.name = name; this.readSubDirs = false; files = new String[1]; files[0] = name; if (program.use_verbose_details()) { program.print("Files in submission '" + name + "':\n", null); for (int i = 0; i < files.length; i++) program.print(" " + files[i] + '\n', null); } }
private void copyFile(File in, File out) { byte[] buffer = new byte[10000]; try { FileInputStream dis = new FileInputStream(in); FileOutputStream dos = new FileOutputStream(out); int count; do { count = dis.read(buffer); if (count != -1) dos.write(buffer, 0, count); } while (count != -1); dis.close(); dos.close(); } catch (IOException e) { program.print("Error copying file: " + e.toString() + "\n", null); } }
private void readIncludeFile() { if (options.include_file == null) return; included = new Vector<String>(); try { BufferedReader in = new BufferedReader(new FileReader(options.include_file)); String line; while ((line = in.readLine()) != null) { included.addElement(line.trim()); } in.close(); } catch (FileNotFoundException e) { System.out.println("Include file not found: " + options.include_file); } catch (IOException e) { } print(null, "Included dirs:\n"); if (options.verbose_long) { Enumeration<String> enum1 = included.elements(); while (enum1.hasMoreElements()) print(null, " " + enum1.nextElement() + "\n"); } }
public Submission(String name, File dir, boolean readSubDirs, Program p, Language language) { this.program = p; this.language = language; this.dir = dir; this.name = name; this.readSubDirs = readSubDirs; try { lookupDir(dir, ""); } catch (Throwable b) { } if (program.use_verbose_details()) { program.print("Files in submission '" + name + "':\n", null); for (int i = 0; i < files.length; i++) program.print(" " + files[i] + '\n', null); } }
private void readExclusionFile() { if (options.exclude_file == null) return; excluded = new HashSet<String>(); try { BufferedReader in = new BufferedReader(new FileReader(options.exclude_file)); String line; while ((line = in.readLine()) != null) { excluded.add(line.trim()); } in.close(); } catch (FileNotFoundException e) { System.out.println("Exclusion file not found: " + options.exclude_file); } catch (IOException e) { } print(null, "Excluded files:\n"); if (options.verbose_long) { Iterator<String> iter = excluded.iterator(); while (iter.hasNext()) { print(null, " " + iter.next() + "\n"); } } }
private void writeTextResult(File dir, SortedVector<AllMatches> matches) { Iterator<AllMatches> iter = matches.iterator(); print("Writing special 'matches.txt' file\n", null); try { File f = new File(dir, "matches.txt"); PrintWriter writer = new PrintWriter(new FileWriter(f)); while (iter.hasNext()) { AllMatches match = iter.next(); String file1, file2, tmp; file1 = match.subA.name; file2 = match.subB.name; if (file1.compareTo(file2) > 0) { tmp = file2; file2 = file1; file1 = tmp; } writer.println(file1 + "\t" + file2 + "\t" + match.percent()); } writer.close(); } catch (IOException e) { print("IOException while writing file\n", null); } } }
private void makeTempDir() throws jplag.ExitException { print(null, "Creating temporary dir.\n"); File f = new File("temp"); if (!f.exists()) { if (!f.mkdirs()) { throw new jplag.ExitException("Cannot create temporary directory!"); } } if (!f.isDirectory()) { throw new ExitException("'temp' is not a directory!"); } if (!f.canWrite()) { throw new ExitException("Cannot write directory: 'temp'"); } }
boolean removed = false; Submission subm = iter.next(); print(null, "------ Parsing submission: " + subm.name + "\n"); currentSubmissionName = subm.name; options.setProgress(count * 100 / totalcount); print(null, "Submission contains fewer tokens than minimum match " + "length allows!\n"); subm.struct = null; invalid++; print(null, "OK\n"); else print(null, "ERROR -> Submission removed\n"); print("\n" + (count - errors - invalid) + " submissions parsed successfully!\n" + errors + " parser error" + (errors != 1 ? "s!\n" : "!\n"), null); if (invalid != 0) { print(null, invalid + ((invalid == 1) ? " submission is not valid because it contains" : " submissions are not valid because they contain") + " fewer tokens\nthan minimum match length allows.\n"); print("\n\n", "\nTotal time for parsing: " + ((time / 3600000 > 0) ? (time / 3600000) + " h " : "") + ((time / 60000 > 0) ? ((time / 60000) % 60000) + " min " : "") + (time / 1000 % 60) + " sec\n" + "Time per parsed submission: " + (count > 0 ? (time / count) : "n/a") + " msec\n\n");
private void writeResults(int[] dist, SortedVector<AllMatches> avgmatches, SortedVector<AllMatches> maxmatches, SortedVector<AllMatches> minmatches, Cluster clustering) throws jplag.ExitException { options.setState(Options.GENERATING_RESULT_FILES); options.setProgress(0); if (options.original_dir == null) print("Writing results to: " + options.result_dir + "\n", null); File f = new File(options.result_dir); if (!f.exists()) if (!f.mkdirs()) { throw new jplag.ExitException("Cannot create directory!"); } if (!f.isDirectory()) { throw new jplag.ExitException(options.result_dir + " is not a directory!"); } if (!f.canWrite()) { throw new jplag.ExitException("Cannot write directory: " + options.result_dir); } this.report.write(f, dist, avgmatches, maxmatches, minmatches, clustering, options); if (options.externalSearch) writeTextResult(f, avgmatches); }
print("----- Parsing basecode submission: " + subm.name + "\n", null); print("\nBasecode submission parsed!\n", null); long time = System.currentTimeMillis() - msec; print("\n", "\nTime for parsing Basecode: " + ((time / 3600000 > 0) ? (time / 3600000) + " h " : "") + ((time / 60000 > 0) ? ((time / 60000) % 60000) + " min " : "") + (time / 1000 % 60) + " sec\n");
public boolean parse() throws jplag.ExitException { if (!program.use_verbose_parser()) { if (files == null || files.length == 0) { program.print("ERROR: nothing to parse for submission \"" + name + "\"\n", null); return false; } } struct = this.language.parse(dir, files); if (!language.errors()) { if (struct.size() < 3) { program.print("Submission \"" + name + "\" is too short!\n", null); struct = null; errors = true; // invalidate submission return false; } return true; } struct = null; errors = true; // invalidate submission if (program.use_debugParser()) copySubmission(); return false; }
print("\n\n", "\nTime for comparing with Basecode: " + ((timebc / 3600000 > 0) ? (timebc / 3600000) + " h " : "") + ((timebc / 60000 > 0) ? ((timebc / 60000) % 60000) + " min " : "") + (timebc / 1000 % 60) + " sec\n" + "Time per basecode comparison: " + (timebc / size) + " msec\n\n"); long time = System.currentTimeMillis() - msec; print("\n", "Total time for comparing submissions: " + ((time / 3600000 > 0) ? (time / 3600000) + " h " : "") + ((time / 60000 > 0) ? ((time / 60000) % 60000) + " min " : "") + (time / 1000 % 60) + " sec\n" + "Time per comparison: " + (time / anz) + " msec\n");
print("\n\n", "\nTime for comparing with Basecode: " + ((timebc / 3600000 > 0) ? (timebc / 3600000) + " h " : "") + ((timebc / 60000 > 0) ? ((timebc / 60000) % 60000) + " min " : "") + (timebc / 1000 % 60) + " sec\n" + "Time per basecode comparison: " + (timebc / size) + " msec\n\n"); long time = System.currentTimeMillis() - msec; print("\n", "Total time for comparing submissions: " + ((time / 3600000 > 0) ? (time / 3600000) + " h " : "") + ((time / 60000 > 0) ? ((time / 60000) % 60000) + " min " : "") + (time / 1000 % 60) + " sec\n" + "Time per comparison: " + (time / anz) + " msec\n");
int matchIndex = 0; print("Comparing: ", validSubmissions() + " submissions"); print("\n(Writing results at the same time.)\n", null); print("\n", "Total time: " + ((time / 3600000 > 0) ? (time / 3600000) + " h " : "") + ((time / 60000 > 0) ? ((time / 60000) % 60000) + " min " : "") + (time / 1000 % 60) + " sec\n" + "Time per comparison: " + (time / anz) + " msec\n");