You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@joshua.apache.org by mj...@apache.org on 2016/05/17 00:16:04 UTC
[1/6] incubator-joshua git commit: System.exit() removed and replaced
with RuntimeException(...)
Repository: incubator-joshua
Updated Branches:
refs/heads/JOSHUA-264 [created] 659e46466
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/zmert/MertCore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/zmert/MertCore.java b/src/main/java/org/apache/joshua/zmert/MertCore.java
index fbcfdbc..44ac700 100644
--- a/src/main/java/org/apache/joshua/zmert/MertCore.java
+++ b/src/main/java/org/apache/joshua/zmert/MertCore.java
@@ -293,8 +293,7 @@ public class MertCore {
if (! new File(refFile).exists())
refFile = refFileName + ".0";
if (! new File(refFile).exists()) {
- System.err.println(String.format("* FATAL: can't find first reference file '%s{0,.0}'", refFileName));
- System.exit(1);
+ throw new RuntimeException(String.format("* FATAL: can't find first reference file '%s{0,.0}'", refFileName));
}
numSentences = countLines(refFile);
@@ -341,12 +340,8 @@ public class MertCore {
}
inFile_names.close();
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MertCore.initialize(int): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MertCore.initialize(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
processParamFile();
@@ -369,8 +364,7 @@ public class MertCore {
if (! new File(refFile).exists())
refFile = refFileName + "." + i;
if (! new File(refFile).exists()) {
- System.err.println(String.format("* FATAL: can't find reference file '%s'", refFile));
- System.exit(1);
+ throw new RuntimeException(String.format("* FATAL: can't find reference file '%s'", refFile));
}
reference_readers[i] = new BufferedReader(new InputStreamReader(new FileInputStream(new File(refFile)), "utf8"));
@@ -397,12 +391,8 @@ public class MertCore {
inFile_comm.close();
}
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MertCore.initialize(int): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MertCore.initialize(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
@@ -1479,21 +1469,15 @@ public class MertCore {
int decStatus = p.waitFor();
if (decStatus != validDecoderExitValue) {
- println("Call to decoder returned " + decStatus + "; was expecting "
+ throw new RuntimeException("Call to decoder returned " + decStatus + "; was expecting "
+ validDecoderExitValue + ".");
- System.exit(30);
}
- } catch (IOException e) {
- System.err.println("IOException in MertCore.run_decoder(int): " + e.getMessage());
- System.exit(99902);
- } catch (InterruptedException e) {
- System.err.println("InterruptedException in MertCore.run_decoder(int): " + e.getMessage());
- System.exit(99903);
+ } catch (IOException| InterruptedException e) {
+ throw new RuntimeException(e);
}
retSA[0] = decoderOutFileName;
retSA[1] = "1";
-
}
return retSA;
@@ -1598,13 +1582,8 @@ public class MertCore {
gzipFile(featsFileName);
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MertCore.produceTempFiles(int): "
- + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MertCore.produceTempFiles(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -1640,9 +1619,7 @@ public class MertCore {
inFile.close();
outFile.close();
} catch (IOException e) {
- System.err.println("IOException in MertCore.createConfigFile(double[],String,String): "
- + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -1652,8 +1629,7 @@ public class MertCore {
try {
inFile_init = new Scanner(new FileReader(paramsFileName));
} catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MertCore.processParamFile(): " + e.getMessage());
- System.exit(99901);
+ throw new RuntimeException("FileNotFoundException in MertCore.processParamFile(): " + e.getMessage());
}
String dummy = "";
@@ -1676,8 +1652,8 @@ public class MertCore {
} else if (dummy.equals("Fix")) {
isOptimizable[c] = false;
} else {
- println("Unknown isOptimizable string " + dummy + " (must be either Opt or Fix)");
- System.exit(21);
+ throw new RuntimeException("Unknown isOptimizable string " + dummy
+ + " (must be either Opt or Fix)");
}
if (!isOptimizable[c]) { // skip next four values
@@ -1691,16 +1667,14 @@ public class MertCore {
if (dummy.equals("-Inf")) {
minThValue[c] = NegInf;
} else if (dummy.equals("+Inf")) {
- println("minThValue[" + c + "] cannot be +Inf!");
- System.exit(21);
+ throw new RuntimeException("minThValue[" + c + "] cannot be +Inf!");
} else {
minThValue[c] = Double.parseDouble(dummy);
}
dummy = inFile_init.next();
if (dummy.equals("-Inf")) {
- println("maxThValue[" + c + "] cannot be -Inf!");
- System.exit(21);
+ throw new RuntimeException("maxThValue[" + c + "] cannot be -Inf!");
} else if (dummy.equals("+Inf")) {
maxThValue[c] = PosInf;
} else {
@@ -1710,16 +1684,14 @@ public class MertCore {
// set minRandValue[c] and maxRandValue[c] (range for random values)
dummy = inFile_init.next();
if (dummy.equals("-Inf") || dummy.equals("+Inf")) {
- println("minRandValue[" + c + "] cannot be -Inf or +Inf!");
- System.exit(21);
+ throw new RuntimeException("minRandValue[" + c + "] cannot be -Inf or +Inf!");
} else {
minRandValue[c] = Double.parseDouble(dummy);
}
dummy = inFile_init.next();
if (dummy.equals("-Inf") || dummy.equals("+Inf")) {
- println("maxRandValue[" + c + "] cannot be -Inf or +Inf!");
- System.exit(21);
+ throw new RuntimeException("maxRandValue[" + c + "] cannot be -Inf or +Inf!");
} else {
maxRandValue[c] = Double.parseDouble(dummy);
}
@@ -1727,14 +1699,12 @@ public class MertCore {
// check for illogical values
if (minThValue[c] > maxThValue[c]) {
- println("minThValue[" + c + "]=" + minThValue[c] + " > " + maxThValue[c] + "=maxThValue["
- + c + "]!");
- System.exit(21);
+ throw new RuntimeException("minThValue[" + c + "]=" + minThValue[c]
+ + " > " + maxThValue[c] + "=maxThValue[" + c + "]!");
}
if (minRandValue[c] > maxRandValue[c]) {
- println("minRandValue[" + c + "]=" + minRandValue[c] + " > " + maxRandValue[c]
- + "=maxRandValue[" + c + "]!");
- System.exit(21);
+ throw new RuntimeException("minRandValue[" + c + "]=" + minRandValue[c]
+ + " > " + maxRandValue[c] + "=maxRandValue[" + c + "]!");
}
// check for odd values
@@ -1804,40 +1774,34 @@ public class MertCore {
normalizationOptions[2] = c_fromParamName(pName);;
if (normalizationOptions[1] <= 0) {
- println("Value for the absval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the absval normalization method must be positive.");
}
if (normalizationOptions[2] == 0) {
- println("Unrecognized feature name " + normalizationOptions[2]
- + " for absval normalization method.", 1);
- System.exit(21);
+ throw new RuntimeException("Unrecognized feature name " + normalizationOptions[2]
+ + " for absval normalization method.");
}
} else if (dummyA[0].equals("maxabsval")) {
normalizationOptions[0] = 2;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
if (normalizationOptions[1] <= 0) {
- println("Value for the maxabsval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the maxabsval normalization method must be positive.");
}
} else if (dummyA[0].equals("minabsval")) {
normalizationOptions[0] = 3;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
if (normalizationOptions[1] <= 0) {
- println("Value for the minabsval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the minabsval normalization method must be positive.");
}
} else if (dummyA[0].equals("LNorm")) {
normalizationOptions[0] = 4;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
normalizationOptions[2] = Double.parseDouble(dummyA[2]);
if (normalizationOptions[1] <= 0 || normalizationOptions[2] <= 0) {
- println("Both values for the LNorm normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Both values for the LNorm normalization method must be positive.");
}
} else {
- println("Unrecognized normalization method " + dummyA[0] + "; "
+ throw new RuntimeException("Unrecognized normalization method " + dummyA[0] + "; "
+ "must be one of none, absval, maxabsval, and LNorm.");
- System.exit(21);
} // if (dummyA[0])
inFile_init.close();
@@ -1947,12 +1911,8 @@ public class MertCore {
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MertCore.processDocInfo(): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MertCore.processDocInfo(): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2052,8 +2012,7 @@ public class MertCore {
outFile_lambdas.close();
} catch (IOException e) {
- System.err.println("IOException in MertCore.finish(): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2105,13 +2064,9 @@ public class MertCore {
inFile.close();
} catch (FileNotFoundException e) {
- println("Z-MERT configuration file " + fileName + " was not found!");
- System.err.println("FileNotFoundException in MertCore.cfgFileToArgsArray(String): "
- + e.getMessage());
- System.exit(99901);
+ throw new RuntimeException("Z-MERT configuration file " + fileName + " was not found!", e);
} catch (IOException e) {
- System.err.println("IOException in MertCore.cfgFileToArgsArray(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
String[] argsArray = new String[argsVector.size()];
@@ -2194,14 +2149,12 @@ public class MertCore {
} else if (option.equals("-rps")) {
refsPerSen = Integer.parseInt(args[i + 1]);
if (refsPerSen < 1) {
- println("refsPerSen must be positive.");
- System.exit(10);
+ throw new RuntimeException("refsPerSen must be positive.");
}
} else if (option.equals("-txtNrm")) {
textNormMethod = Integer.parseInt(args[i + 1]);
if (textNormMethod < 0 || textNormMethod > 4) {
- println("textNormMethod should be between 0 and 4");
- System.exit(10);
+ throw new RuntimeException("textNormMethod should be between 0 and 4");
}
} else if (option.equals("-p")) {
paramsFileName = args[i + 1];
@@ -2221,8 +2174,7 @@ public class MertCore {
}
i += optionCount;
} else {
- println("Unknown metric name " + metricName + ".");
- System.exit(10);
+ throw new RuntimeException("Unknown metric name " + metricName + ".");
}
} else if (option.equals("-docSet")) {
String method = args[i + 1];
@@ -2267,32 +2219,27 @@ public class MertCore {
docSubsetInfo[6] = Integer.parseInt(a2);
i += 3;
} else {
- println("Unknown docSet method " + method + ".");
- System.exit(10);
+ throw new RuntimeException("Unknown docSet method " + method + ".");
}
} else if (option.equals("-maxIt")) {
maxMERTIterations = Integer.parseInt(args[i + 1]);
if (maxMERTIterations < 1) {
- println("maxMERTIts must be positive.");
- System.exit(10);
+ throw new RuntimeException("maxMERTIts must be positive.");
}
} else if (option.equals("-minIt")) {
minMERTIterations = Integer.parseInt(args[i + 1]);
if (minMERTIterations < 1) {
- println("minMERTIts must be positive.");
- System.exit(10);
+ throw new RuntimeException("minMERTIts must be positive.");
}
} else if (option.equals("-prevIt")) {
prevMERTIterations = Integer.parseInt(args[i + 1]);
if (prevMERTIterations < 0) {
- println("prevMERTIts must be non-negative.");
- System.exit(10);
+ throw new RuntimeException("prevMERTIts must be non-negative.");
}
} else if (option.equals("-stopIt")) {
stopMinIts = Integer.parseInt(args[i + 1]);
if (stopMinIts < 1) {
- println("stopMinIts must be positive.");
- System.exit(10);
+ throw new RuntimeException("stopMinIts must be positive.");
}
} else if (option.equals("-stopSig")) {
stopSigValue = Double.parseDouble(args[i + 1]);
@@ -2303,26 +2250,22 @@ public class MertCore {
else if (option.equals("-thrCnt")) {
numOptThreads = Integer.parseInt(args[i + 1]);
if (numOptThreads < 1) {
- println("threadCount must be positive.");
- System.exit(10);
+ throw new RuntimeException("threadCount must be positive.");
}
} else if (option.equals("-save")) {
saveInterFiles = Integer.parseInt(args[i + 1]);
if (saveInterFiles < 0 || saveInterFiles > 3) {
- println("save should be between 0 and 3");
- System.exit(10);
+ throw new RuntimeException("save should be between 0 and 3");
}
} else if (option.equals("-compress")) {
compressFiles = Integer.parseInt(args[i + 1]);
if (compressFiles < 0 || compressFiles > 1) {
- println("compressFiles should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("compressFiles should be either 0 or 1");
}
} else if (option.equals("-ipi")) {
initsPerIt = Integer.parseInt(args[i + 1]);
if (initsPerIt < 1) {
- println("initsPerIt must be positive.");
- System.exit(10);
+ throw new RuntimeException("initsPerIt must be positive.");
}
} else if (option.equals("-opi")) {
int opi = Integer.parseInt(args[i + 1]);
@@ -2331,8 +2274,7 @@ public class MertCore {
} else if (opi == 0) {
oneModificationPerIteration = false;
} else {
- println("oncePerIt must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("oncePerIt must be either 0 or 1.");
}
} else if (option.equals("-rand")) {
int rand = Integer.parseInt(args[i + 1]);
@@ -2341,8 +2283,7 @@ public class MertCore {
} else if (rand == 0) {
randInit = false;
} else {
- println("randInit must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("randInit must be either 0 or 1.");
}
} else if (option.equals("-seed")) {
if (args[i + 1].equals("time")) {
@@ -2361,8 +2302,7 @@ public class MertCore {
} else if (option.equals("-passIt")) {
int val = Integer.parseInt(args[i + 1]);
if (val < 0 || val > 1) {
- println("passIterationToDecoder should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("passIterationToDecoder should be either 0 or 1");
}
passIterationToDecoder = (val == 1) ? true : false;
} else if (option.equals("-decOut")) {
@@ -2374,44 +2314,38 @@ public class MertCore {
} else if (option.equals("-N")) {
sizeOfNBest = Integer.parseInt(args[i + 1]);
if (sizeOfNBest < 1) {
- println("N must be positive.");
- System.exit(10);
+ throw new RuntimeException("N must be positive.");
}
}
// Output specs
else if (option.equals("-v")) {
verbosity = Integer.parseInt(args[i + 1]);
if (verbosity < 0 || verbosity > 4) {
- println("verbosity should be between 0 and 4");
- System.exit(10);
+ throw new RuntimeException("verbosity should be between 0 and 4");
}
} else if (option.equals("-decV")) {
decVerbosity = Integer.parseInt(args[i + 1]);
if (decVerbosity < 0 || decVerbosity > 1) {
- println("decVerbosity should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("decVerbosity should be either 0 or 1");
}
} else if (option.equals("-fake")) {
fakeFileNameTemplate = args[i + 1];
int QM_i = fakeFileNameTemplate.indexOf("?");
if (QM_i <= 0) {
- println("fakeFileNameTemplate must contain '?' to indicate position of iteration number");
- System.exit(10);
+ throw new RuntimeException("fakeFileNameTemplate must contain '?' to indicate position of iteration number");
}
fakeFileNamePrefix = fakeFileNameTemplate.substring(0, QM_i);
fakeFileNameSuffix = fakeFileNameTemplate.substring(QM_i + 1);
} else if (option.equals("-damianos")) {
damianos_method = Integer.parseInt(args[i + 1]);
if (damianos_method < 0 || damianos_method > 3) {
- println("damianos_method should be between 0 and 3");
- System.exit(10);
+ throw new RuntimeException("damianos_method should be between 0 and 3");
}
damianos_param = Double.parseDouble(args[i + 2]);
damianos_mult = Double.parseDouble(args[i + 3]);
i += 2;
} else {
- println("Unknown option " + option);
- System.exit(10);
+ throw new RuntimeException("Unknown option " + option);
}
i += 2;
@@ -2483,10 +2417,10 @@ public class MertCore {
if (!canRunCommand && !canRunJoshua) { // can only run fake decoder
if (!canRunFake) {
- println("Z-MERT cannot decode; must provide one of: command file (for external decoder),");
- println(" source file (for Joshua decoder),");
- println(" or prefix for existing output files (for fake decoder).");
- System.exit(12);
+ String msg = "Z-MERT cannot decode; must provide one of: command file "
+ + "(for external decoder) source file (for Joshua decoder),"
+ + " or prefix for existing output files (for fake decoder).";
+ throw new RuntimeException(msg);
}
int lastGoodIt = 0;
@@ -2499,9 +2433,8 @@ public class MertCore {
}
if (lastGoodIt == 0) {
- println("Fake decoder cannot find first output file "
+ throw new RuntimeException("Fake decoder cannot find first output file "
+ (fakeFileNamePrefix + 1 + fakeFileNameSuffix));
- System.exit(13);
} else if (lastGoodIt < maxMERTIterations) {
if (firstTime)
println("Warning: can only run fake decoder; existing output files "
@@ -2583,8 +2516,7 @@ public class MertCore {
private void checkFile(String fileName) {
if (!fileExists(fileName)) {
- println("The file " + fileName + " was not found!");
- System.exit(40);
+ throw new RuntimeException("The file " + fileName + " was not found!");
}
}
@@ -2618,8 +2550,7 @@ public class MertCore {
deleteFile(inputFileName);
} catch (IOException e) {
- System.err.println("IOException in MertCore.gzipFile(String,String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2777,8 +2708,7 @@ public class MertCore {
inFile.close();
} catch (IOException e) {
- System.err.println("IOException in MertCore.countLines(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return count;
@@ -2798,8 +2728,7 @@ public class MertCore {
inFile.close();
} catch (IOException e) {
- System.err.println("IOException in MertCore.countNonEmptyLines(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return count;
[2/6] incubator-joshua git commit: System.exit() removed and replaced
with RuntimeException(...)
Posted by mj...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/METEOR.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/METEOR.java b/src/main/java/org/apache/joshua/metrics/METEOR.java
index 7ed0796..33232db 100644
--- a/src/main/java/org/apache/joshua/metrics/METEOR.java
+++ b/src/main/java/org/apache/joshua/metrics/METEOR.java
@@ -52,9 +52,9 @@ public class METEOR extends EvaluationMetric {
} else if (Metric_options[0].equals("es")) {
targetLanguage = "es";
} else {
- System.out.println("Unknown language string " + Metric_options[0] + ".");
- System.out.println("Should be one of {en,cz,fr,de,es}.");
- System.exit(1);
+ String msg = "Unknown language string " + Metric_options[0]
+ + ". Should be one of {en,cz,fr,de,es}.";
+ throw new RuntimeException(msg);
}
if (Metric_options[1].equals("norm_yes")) {
@@ -62,9 +62,9 @@ public class METEOR extends EvaluationMetric {
} else if (Metric_options[1].equals("norm_no")) {
normalize = false;
} else {
- System.out.println("Unknown normalize string " + Metric_options[1] + ".");
- System.out.println("Should be one of norm_yes or norm_no.");
- System.exit(1);
+ String msg = "Unknown normalize string " + Metric_options[1]
+ + ". Should be one of norm_yes or norm_no.";
+ throw new RuntimeException(msg);
}
if (Metric_options[2].equals("keepPunc")) {
@@ -72,15 +72,14 @@ public class METEOR extends EvaluationMetric {
} else if (Metric_options[1].equals("removePunk")) {
keepPunctuation = false;
} else {
- System.out.println("Unknown keepPunctuation string " + Metric_options[1] + ".");
- System.out.println("Should be one of keepPunc or removePunk.");
- System.exit(1);
+ String msg = "Unknown keepPunctuation string " + Metric_options[1]
+ + ". Should be one of keepPunc or removePunk.";
+ throw new RuntimeException(msg);
}
maxComputations = Integer.parseInt(Metric_options[3]);
if (maxComputations < 1) {
- System.out.println("Maximum computations must be positive");
- System.exit(2);
+ throw new RuntimeException("Maximum computations must be positive");
}
initialize(); // set the data members of the metric
@@ -124,7 +123,7 @@ public class METEOR extends EvaluationMetric {
// 1a) Create hypothesis file
FileOutputStream outStream = new FileOutputStream("hyp.txt.METEOR", false); // false: don't
- // append
+ // append
OutputStreamWriter outStreamWriter = new OutputStreamWriter(outStream, "utf8");
BufferedWriter outFile = new BufferedWriter(outStreamWriter);
@@ -191,15 +190,10 @@ public class METEOR extends EvaluationMetric {
stats[d][3] = (int) Double.parseDouble(strA[3]);
stats[d][4] = (int) Double.parseDouble(strA[4]);
}
-
+
inFile.close();
- } catch (IOException e) {
- System.err.println("IOException in METEOR.suffStats(String[],int[]): " + e.getMessage());
- System.exit(99902);
- } catch (InterruptedException e) {
- System.err.println("InterruptedException in METEOR.suffStats(String[],int[]): "
- + e.getMessage());
- System.exit(99903);
+ } catch (IOException | InterruptedException e) {
+ throw new RuntimeException(e);
}
return stats;
@@ -207,9 +201,8 @@ public class METEOR extends EvaluationMetric {
public double score(int[] stats) {
if (stats.length != suffStatsCount) {
- System.out.println("Mismatch between stats.length and suffStatsCount (" + stats.length
+ throw new RuntimeException("Mismatch between stats.length and suffStatsCount (" + stats.length
+ " vs. " + suffStatsCount + ") in METEOR.score(int[])");
- System.exit(1);
}
double sc = 0.0;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/MinimumChangeBLEU.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/MinimumChangeBLEU.java b/src/main/java/org/apache/joshua/metrics/MinimumChangeBLEU.java
index c759d0e..908e266 100644
--- a/src/main/java/org/apache/joshua/metrics/MinimumChangeBLEU.java
+++ b/src/main/java/org/apache/joshua/metrics/MinimumChangeBLEU.java
@@ -171,9 +171,10 @@ public class MinimumChangeBLEU extends BLEU {
public double score(int[] stats) {
if (stats.length != suffStatsCount) {
- logger.severe("Mismatch between stats.length and " + "suffStatsCount (" + stats.length
- + " vs. " + suffStatsCount + ") in BLEU.score(int[])");
- System.exit(2);
+ String msg ="Mismatch between stats.length and " + "suffStatsCount (" + stats.length
+ + " vs. " + suffStatsCount + ") in BLEU.score(int[])";
+ logger.severe(msg);
+ throw new RuntimeException(msg);
}
double accuracy = 0.0;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/Precis.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/Precis.java b/src/main/java/org/apache/joshua/metrics/Precis.java
index 5bdd4c7..6db1d66 100644
--- a/src/main/java/org/apache/joshua/metrics/Precis.java
+++ b/src/main/java/org/apache/joshua/metrics/Precis.java
@@ -241,9 +241,10 @@ public class Precis extends BLEU {
// calculate the actual score from the statistics
public double score(int[] stats) {
if (stats.length != suffStatsCount) {
- logger.severe("Mismatch between stats.length and suffStatsCount (" + stats.length + " vs. "
- + suffStatsCount + ") in Precis.score(int[])");
- System.exit(2);
+ String msg = "Mismatch between stats.length and suffStatsCount (" + stats.length + " vs. "
+ + suffStatsCount + ") in Precis.score(int[])";
+ logger.severe(msg);
+ throw new RuntimeException(msg);
}
double accuracy = 0.0;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/PrecisMinusSourceBLEU.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/PrecisMinusSourceBLEU.java b/src/main/java/org/apache/joshua/metrics/PrecisMinusSourceBLEU.java
index 461243c..bfe15d0 100644
--- a/src/main/java/org/apache/joshua/metrics/PrecisMinusSourceBLEU.java
+++ b/src/main/java/org/apache/joshua/metrics/PrecisMinusSourceBLEU.java
@@ -132,16 +132,14 @@ public class PrecisMinusSourceBLEU extends EvaluationMetric {
fd = new File(outputFileName + ".SRC_BLEU");
if (fd.exists()) fd.delete();
} catch (IOException e) {
- System.err.println("IOException: " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
public double score(int[] stats) {
if (stats.length != suffStatsCount) {
- System.out.println("Mismatch between stats.length and suffStatsCount (" + stats.length
+ throw new RuntimeException("Mismatch between stats.length and suffStatsCount (" + stats.length
+ " vs. " + suffStatsCount + ") in PrecisMinusSourceBLEU.score(int[])");
- System.exit(1);
}
double sc = 0.0;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/TER.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/TER.java b/src/main/java/org/apache/joshua/metrics/TER.java
index 2e37c11..0dcf9d9 100644
--- a/src/main/java/org/apache/joshua/metrics/TER.java
+++ b/src/main/java/org/apache/joshua/metrics/TER.java
@@ -57,9 +57,9 @@ public class TER extends EvaluationMetric {
} else if (Metric_options[0].equals("nocase")) {
caseSensitive = false;
} else {
- System.out.println("Unknown case sensitivity string " + Metric_options[0] + ".");
- System.out.println("Should be one of case or nocase.");
- System.exit(1);
+ String msg = "Unknown case sensitivity string " + Metric_options[0]
+ + ". Should be one of case or nocase.";
+ throw new RuntimeException(msg);
}
if (Metric_options[1].equals("punc")) {
@@ -67,41 +67,37 @@ public class TER extends EvaluationMetric {
} else if (Metric_options[1].equals("nopunc")) {
withPunctuation = false;
} else {
- System.out.println("Unknown with-punctuation string " + Metric_options[1] + ".");
- System.out.println("Should be one of punc or nopunc.");
- System.exit(1);
+ String msg = "Unknown with-punctuation string " + Metric_options[1]
+ + ". Should be one of punc or nopunc.";
+ throw new RuntimeException(msg);
}
beamWidth = Integer.parseInt(Metric_options[2]);
if (beamWidth < 1) {
- System.out.println("Beam width must be positive");
- System.exit(1);
+ throw new RuntimeException("Beam width must be positive");
}
maxShiftDist = Integer.parseInt(Metric_options[3]);
if (maxShiftDist < 1) {
- System.out.println("Maximum shift distance must be positive");
- System.exit(1);
+ throw new RuntimeException("Maximum shift distance must be positive");
}
tercomJarFileName = Metric_options[4];
if (tercomJarFileName == null || tercomJarFileName.equals("")) {
- System.out.println("Problem processing tercom's jar filename");
- System.exit(1);
+ throw new RuntimeException("Problem processing tercom's jar filename");
} else {
File checker = new File(tercomJarFileName);
if (!checker.exists()) {
- System.out.println("Could not find tercom jar file " + tercomJarFileName);
- System.out.println("(Please make sure you use the full path in the filename)");
- System.exit(1);
+ String msg = "Could not find tercom jar file " + tercomJarFileName
+ + "(Please make sure you use the full path in the filename)";
+ throw new RuntimeException(msg);
}
}
numScoringThreads = Integer.parseInt(Metric_options[5]);
if (numScoringThreads < 1) {
- System.out.println("Number of TER scoring threads must be positive");
- System.exit(1);
+ throw new RuntimeException("Number of TER scoring threads must be positive");
}
@@ -206,8 +202,7 @@ public class TER extends EvaluationMetric {
if (fd.exists()) fd.delete();
} catch (IOException e) {
- System.err.println("IOException in TER.suffStats(String[],int[]): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return stats;
@@ -259,9 +254,7 @@ public class TER extends EvaluationMetric {
try {
blocker.acquire(batchCount);
} catch (java.lang.InterruptedException e) {
- System.err.println("InterruptedException in TER.createSuffStatsFile(...): "
- + e.getMessage());
- System.exit(99906);
+ throw new RuntimeException(e);
}
PrintWriter outFile = new PrintWriter(outputFileName);
@@ -275,8 +268,7 @@ public class TER extends EvaluationMetric {
outFile.close();
} catch (IOException e) {
- System.err.println("IOException in TER.createSuffStatsFile(...): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -317,8 +309,7 @@ public class TER extends EvaluationMetric {
outFile.close();
} catch (IOException e) {
- System.err.println("IOException in TER.createTercomHypFile(...): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException("IOException in TER.createTercomHypFile(...): " + e.getMessage(), e);
}
return readCount;
@@ -367,8 +358,7 @@ public class TER extends EvaluationMetric {
outFile.close();
} catch (IOException e) {
- System.err.println("IOException in TER.createTercomRefFile(...): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return readCount;
@@ -407,12 +397,8 @@ public class TER extends EvaluationMetric {
exitValue = p.waitFor();
- } catch (IOException e) {
- System.err.println("IOException in TER.runTercom(...): " + e.getMessage());
- System.exit(99902);
- } catch (InterruptedException e) {
- System.err.println("InterruptedException in TER.runTercom(...): " + e.getMessage());
- System.exit(99903);
+ } catch (IOException | InterruptedException e) {
+ throw new RuntimeException(e);
}
return exitValue;
@@ -438,16 +424,14 @@ public class TER extends EvaluationMetric {
inFile.close();
} catch (IOException e) {
- System.err.println("IOException in TER.copySS(String,PrintWriter): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
public double score(int[] stats) {
if (stats.length != suffStatsCount) {
- System.out.println("Mismatch between stats.length and suffStatsCount (" + stats.length
+ throw new RuntimeException("Mismatch between stats.length and suffStatsCount (" + stats.length
+ " vs. " + suffStatsCount + ") in TER.score(int[])");
- System.exit(2);
}
double sc = 0.0;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/TERMinusBLEU.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/TERMinusBLEU.java b/src/main/java/org/apache/joshua/metrics/TERMinusBLEU.java
index 5208546..bd40140 100644
--- a/src/main/java/org/apache/joshua/metrics/TERMinusBLEU.java
+++ b/src/main/java/org/apache/joshua/metrics/TERMinusBLEU.java
@@ -144,16 +144,14 @@ public class TERMinusBLEU extends EvaluationMetric {
fd = new File(outputFileName + ".BLEU");
if (fd.exists()) fd.delete();
} catch (IOException e) {
- System.err.println("IOException in TER.createTercomHypFile(...): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException("IOException in TER.createTercomHypFile(...): " + e.getMessage());
}
}
public double score(int[] stats) {
if (stats.length != suffStatsCount) {
- System.out.println("Mismatch between stats.length and suffStatsCount (" + stats.length
+ throw new RuntimeException("Mismatch between stats.length and suffStatsCount (" + stats.length
+ " vs. " + suffStatsCount + ") in TERMinusBLEU.score(int[])");
- System.exit(1);
}
double sc = 0.0;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/TercomRunner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/TercomRunner.java b/src/main/java/org/apache/joshua/metrics/TercomRunner.java
index 75a76dc..d7eeae5 100644
--- a/src/main/java/org/apache/joshua/metrics/TercomRunner.java
+++ b/src/main/java/org/apache/joshua/metrics/TercomRunner.java
@@ -96,12 +96,8 @@ public class TercomRunner implements Runnable {
fd = new File(refFileName);
if (fd.exists()) fd.delete();
- } catch (IOException e) {
- System.err.println("IOException in TER.runTercom(...): " + e.getMessage());
- System.exit(99902);
- } catch (InterruptedException e) {
- System.err.println("InterruptedException in TER.runTercom(...): " + e.getMessage());
- System.exit(99903);
+ } catch (IOException| InterruptedException e) {
+ throw new RuntimeException(e);
}
blocker.release();
@@ -112,8 +108,7 @@ public class TercomRunner implements Runnable {
try {
real_run();
} catch (Exception e) {
- System.err.println("Exception in TercomRunner.run(): " + e.getMessage());
- System.exit(99905);
+ throw new RuntimeException(e);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/ZeroOneLoss.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/ZeroOneLoss.java b/src/main/java/org/apache/joshua/metrics/ZeroOneLoss.java
index 3d4b616..aee6bcc 100644
--- a/src/main/java/org/apache/joshua/metrics/ZeroOneLoss.java
+++ b/src/main/java/org/apache/joshua/metrics/ZeroOneLoss.java
@@ -66,9 +66,8 @@ public class ZeroOneLoss extends EvaluationMetric {
public double score(int[] stats) {
if (stats.length != suffStatsCount) {
- System.out.println("Mismatch between stats.length and suffStatsCount (" + stats.length
+ throw new RuntimeException("Mismatch between stats.length and suffStatsCount (" + stats.length
+ " vs. " + suffStatsCount + ") in ZeroOneLoss.score(int[])");
- System.exit(1);
}
return 1.0 - (stats[0] / (double) stats[1]);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/mira/MIRACore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/mira/MIRACore.java b/src/main/java/org/apache/joshua/mira/MIRACore.java
index 045353a..db689bd 100755
--- a/src/main/java/org/apache/joshua/mira/MIRACore.java
+++ b/src/main/java/org/apache/joshua/mira/MIRACore.java
@@ -327,12 +327,8 @@ public class MIRACore {
}
inFile_names.close();
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MIRACore.initialize(int): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MIRACore.initialize(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
// the parameter file contains one line per parameter
@@ -390,12 +386,8 @@ public class MIRACore {
inFile_comm.close();
}
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MIRACore.initialize(int): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MIRACore.initialize(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
// set static data members for the EvaluationMetric class
@@ -1491,16 +1483,11 @@ public class MIRACore {
int decStatus = p.waitFor();
if (decStatus != validDecoderExitValue) {
- println("Call to decoder returned " + decStatus + "; was expecting "
+ throw new RuntimeException("Call to decoder returned " + decStatus + "; was expecting "
+ validDecoderExitValue + ".");
- System.exit(30);
}
- } catch (IOException e) {
- System.err.println("IOException in MIRACore.run_decoder(int): " + e.getMessage());
- System.exit(99902);
- } catch (InterruptedException e) {
- System.err.println("InterruptedException in MIRACore.run_decoder(int): " + e.getMessage());
- System.exit(99903);
+ } catch (IOException| InterruptedException e) {
+ throw new RuntimeException(e);
}
retSA[0] = decoderOutFileName;
@@ -1598,13 +1585,8 @@ public class MIRACore {
gzipFile(featsFileName);
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MIRACore.produceTempFiles(int): "
- + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MIRACore.produceTempFiles(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -1652,9 +1634,7 @@ public class MIRACore {
inFile.close();
outFile.close();
} catch (IOException e) {
- System.err.println("IOException in MIRACore.createConfigFile(double[],String,String): "
- + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -1664,8 +1644,7 @@ public class MIRACore {
try {
inFile_init = new Scanner(new FileReader(paramsFileName));
} catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MIRACore.processParamFile(): " + e.getMessage());
- System.exit(99901);
+ throw new RuntimeException(e);
}
String dummy = "";
@@ -1688,8 +1667,7 @@ public class MIRACore {
} else if (dummy.equals("Fix")) {
isOptimizable[c] = false;
} else {
- println("Unknown isOptimizable string " + dummy + " (must be either Opt or Fix)");
- System.exit(21);
+ throw new RuntimeException("Unknown isOptimizable string " + dummy + " (must be either Opt or Fix)");
}
if (!isOptimizable[c]) { // skip next two values
@@ -1704,25 +1682,22 @@ public class MIRACore {
// set minRandValue[c] and maxRandValue[c] (range for random values)
dummy = inFile_init.next();
if (dummy.equals("-Inf") || dummy.equals("+Inf")) {
- println("minRandValue[" + c + "] cannot be -Inf or +Inf!");
- System.exit(21);
+ throw new RuntimeException("minRandValue[" + c + "] cannot be -Inf or +Inf!");
} else {
minRandValue[c] = Double.parseDouble(dummy);
}
dummy = inFile_init.next();
if (dummy.equals("-Inf") || dummy.equals("+Inf")) {
- println("maxRandValue[" + c + "] cannot be -Inf or +Inf!");
- System.exit(21);
+ throw new RuntimeException("maxRandValue[" + c + "] cannot be -Inf or +Inf!");
} else {
maxRandValue[c] = Double.parseDouble(dummy);
}
// check for illogical values
if (minRandValue[c] > maxRandValue[c]) {
- println("minRandValue[" + c + "]=" + minRandValue[c] + " > " + maxRandValue[c]
- + "=maxRandValue[" + c + "]!");
- System.exit(21);
+ throw new RuntimeException("minRandValue[" + c + "]=" + minRandValue[c]
+ + " > " + maxRandValue[c] + "=maxRandValue[" + c + "]!");
}
// check for odd values
@@ -1773,40 +1748,35 @@ public class MIRACore {
normalizationOptions[2] = Vocabulary.id(pName);
if (normalizationOptions[1] <= 0) {
- println("Value for the absval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the absval normalization method must be positive.");
}
if (normalizationOptions[2] == 0) {
- println("Unrecognized feature name " + normalizationOptions[2]
- + " for absval normalization method.", 1);
- System.exit(21);
+ throw new RuntimeException("Unrecognized feature name " + normalizationOptions[2]
+ + " for absval normalization method.");
}
} else if (dummyA[0].equals("maxabsval")) {
normalizationOptions[0] = 2;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
if (normalizationOptions[1] <= 0) {
- println("Value for the maxabsval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the maxabsval normalization method must be positive.");
}
} else if (dummyA[0].equals("minabsval")) {
normalizationOptions[0] = 3;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
if (normalizationOptions[1] <= 0) {
- println("Value for the minabsval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the minabsval normalization method must be positive.");
}
} else if (dummyA[0].equals("LNorm")) {
normalizationOptions[0] = 4;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
normalizationOptions[2] = Double.parseDouble(dummyA[2]);
if (normalizationOptions[1] <= 0 || normalizationOptions[2] <= 0) {
- println("Both values for the LNorm normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Both values for the LNorm normalization method must be"
+ + " positive.");
}
} else {
- println("Unrecognized normalization method " + dummyA[0] + "; "
+ throw new RuntimeException("Unrecognized normalization method " + dummyA[0] + "; "
+ "must be one of none, absval, maxabsval, and LNorm.");
- System.exit(21);
} // if (dummyA[0])
inFile_init.close();
@@ -1918,12 +1888,8 @@ public class MIRACore {
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MIRACore.processDocInfo(): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MIRACore.processDocInfo(): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2024,8 +1990,7 @@ public class MIRACore {
outFile_lambdas.close();
} catch (IOException e) {
- System.err.println("IOException in MIRACore.finish(): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2106,23 +2071,15 @@ public class MIRACore {
argsVector.add(paramA[opt]);
}
} else {
- println("Malformed line in config file:");
- println(origLine);
- System.exit(70);
+ throw new RuntimeException("Malformed line in config file:" + origLine);
}
}
} while (line != null);
inFile.close();
- } catch (FileNotFoundException e) {
- println("MIRA configuration file " + fileName + " was not found!");
- System.err.println("FileNotFoundException in MIRACore.cfgFileToArgsArray(String): "
- + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MIRACore.cfgFileToArgsArray(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
String[] argsArray = new String[argsVector.size()];
@@ -2200,14 +2157,12 @@ public class MIRACore {
} else if (option.equals("-rps")) {
refsPerSen = Integer.parseInt(args[i + 1]);
if (refsPerSen < 1) {
- println("refsPerSen must be positive.");
- System.exit(10);
+ throw new RuntimeException("refsPerSen must be positive.");
}
} else if (option.equals("-txtNrm")) {
textNormMethod = Integer.parseInt(args[i + 1]);
if (textNormMethod < 0 || textNormMethod > 4) {
- println("textNormMethod should be between 0 and 4");
- System.exit(10);
+ throw new RuntimeException("textNormMethod should be between 0 and 4");
}
} else if (option.equals("-p")) {
paramsFileName = args[i + 1];
@@ -2227,8 +2182,7 @@ public class MIRACore {
}
i += optionCount;
} else {
- println("Unknown metric name " + metricName + ".");
- System.exit(10);
+ throw new RuntimeException("Unknown metric name " + metricName + ".");
}
} else if (option.equals("-docSet")) {
String method = args[i + 1];
@@ -2273,32 +2227,27 @@ public class MIRACore {
docSubsetInfo[6] = Integer.parseInt(a2);
i += 3;
} else {
- println("Unknown docSet method " + method + ".");
- System.exit(10);
+ throw new RuntimeException("Unknown docSet method " + method + ".");
}
} else if (option.equals("-maxIt")) {
maxMERTIterations = Integer.parseInt(args[i + 1]);
if (maxMERTIterations < 1) {
- println("maxIt must be positive.");
- System.exit(10);
+ throw new RuntimeException("maxIt must be positive.");
}
} else if (option.equals("-minIt")) {
minMERTIterations = Integer.parseInt(args[i + 1]);
if (minMERTIterations < 1) {
- println("minIt must be positive.");
- System.exit(10);
+ throw new RuntimeException("minIt must be positive.");
}
} else if (option.equals("-prevIt")) {
prevMERTIterations = Integer.parseInt(args[i + 1]);
if (prevMERTIterations < 0) {
- println("prevIt must be non-negative.");
- System.exit(10);
+ throw new RuntimeException("prevIt must be non-negative.");
}
} else if (option.equals("-stopIt")) {
stopMinIts = Integer.parseInt(args[i + 1]);
if (stopMinIts < 1) {
- println("stopIts must be positive.");
- System.exit(10);
+ throw new RuntimeException("stopIts must be positive.");
}
} else if (option.equals("-stopSig")) {
stopSigValue = Double.parseDouble(args[i + 1]);
@@ -2309,20 +2258,17 @@ public class MIRACore {
else if (option.equals("-thrCnt")) {
numOptThreads = Integer.parseInt(args[i + 1]);
if (numOptThreads < 1) {
- println("threadCount must be positive.");
- System.exit(10);
+ throw new RuntimeException("threadCount must be positive.");
}
} else if (option.equals("-save")) {
saveInterFiles = Integer.parseInt(args[i + 1]);
if (saveInterFiles < 0 || saveInterFiles > 3) {
- println("save should be between 0 and 3");
- System.exit(10);
+ throw new RuntimeException("save should be between 0 and 3");
}
} else if (option.equals("-compress")) {
compressFiles = Integer.parseInt(args[i + 1]);
if (compressFiles < 0 || compressFiles > 1) {
- println("compressFiles should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("compressFiles should be either 0 or 1");
}
} else if (option.equals("-opi")) {
int opi = Integer.parseInt(args[i + 1]);
@@ -2331,8 +2277,7 @@ public class MIRACore {
} else if (opi == 0) {
oneModificationPerIteration = false;
} else {
- println("oncePerIt must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("oncePerIt must be either 0 or 1.");
}
} else if (option.equals("-rand")) {
int rand = Integer.parseInt(args[i + 1]);
@@ -2341,8 +2286,7 @@ public class MIRACore {
} else if (rand == 0) {
randInit = false;
} else {
- println("randInit must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("randInit must be either 0 or 1.");
}
} else if (option.equals("-seed")) {
if (args[i + 1].equals("time")) {
@@ -2364,8 +2308,7 @@ public class MIRACore {
else if (shuffle == 0)
needShuffle = false;
else {
- println("-needShuffle must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-needShuffle must be either 0 or 1.");
}
}
// average weights after each epoch or not
@@ -2376,8 +2319,7 @@ public class MIRACore {
else if (avg == 0)
needAvg = false;
else {
- println("-needAvg must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-needAvg must be either 0 or 1.");
}
}
// return the best weight during tuning or not
@@ -2388,8 +2330,7 @@ public class MIRACore {
else if (retBest == 0)
returnBest = false;
else {
- println("-returnBest must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-returnBest must be either 0 or 1.");
}
}
// run perceptron or not
@@ -2400,8 +2341,7 @@ public class MIRACore {
else if (per == 0)
runPercep = false;
else {
- println("-runPercep must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-runPercep must be either 0 or 1.");
}
}
// oracle selection mode
@@ -2434,8 +2374,7 @@ public class MIRACore {
else if (option.equals("-scoreRatio")) {
scoreRatio = Double.parseDouble(args[i + 1]);
if (scoreRatio <= 0) {
- println("-scoreRatio must be positive");
- System.exit(10);
+ throw new RuntimeException("-scoreRatio must be positive");
}
} else if (option.equals("-needScaling")) {
int scale = Integer.parseInt(args[i + 1]);
@@ -2444,8 +2383,7 @@ public class MIRACore {
else if (scale == 0)
needScale = false;
else {
- println("-needScaling must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-needScaling must be either 0 or 1.");
}
} else if (option.equals("-usePseudoCorpus")) {
int use = Integer.parseInt(args[i + 1]);
@@ -2454,8 +2392,7 @@ public class MIRACore {
else if (use == 0)
usePseudoBleu = false;
else {
- println("-usePseudoCorpus must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-usePseudoCorpus must be either 0 or 1.");
}
} else if (option.equals("-corpusDecay")) {
R = Double.parseDouble(args[i + 1]);
@@ -2467,8 +2404,7 @@ public class MIRACore {
} else if (option.equals("-passIt")) {
int val = Integer.parseInt(args[i + 1]);
if (val < 0 || val > 1) {
- println("passIterationToDecoder should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("passIterationToDecoder should be either 0 or 1");
}
passIterationToDecoder = (val == 1) ? true : false;
} else if (option.equals("-decOut")) {
@@ -2480,35 +2416,30 @@ public class MIRACore {
} else if (option.equals("-N")) {
sizeOfNBest = Integer.parseInt(args[i + 1]);
if (sizeOfNBest < 1) {
- println("N must be positive.");
- System.exit(10);
+ throw new RuntimeException("N must be positive.");
}
}
// Output specs
else if (option.equals("-v")) {
verbosity = Integer.parseInt(args[i + 1]);
if (verbosity < 0 || verbosity > 4) {
- println("verbosity should be between 0 and 4");
- System.exit(10);
+ throw new RuntimeException("verbosity should be between 0 and 4");
}
} else if (option.equals("-decV")) {
decVerbosity = Integer.parseInt(args[i + 1]);
if (decVerbosity < 0 || decVerbosity > 1) {
- println("decVerbosity should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("decVerbosity should be either 0 or 1");
}
} else if (option.equals("-fake")) {
fakeFileNameTemplate = args[i + 1];
int QM_i = fakeFileNameTemplate.indexOf("?");
if (QM_i <= 0) {
- println("fakeFileNameTemplate must contain '?' to indicate position of iteration number");
- System.exit(10);
+ throw new RuntimeException("fakeFileNameTemplate must contain '?' to indicate position of iteration number");
}
fakeFileNamePrefix = fakeFileNameTemplate.substring(0, QM_i);
fakeFileNameSuffix = fakeFileNameTemplate.substring(QM_i + 1);
} else {
- println("Unknown option " + option);
- System.exit(10);
+ throw new RuntimeException("Unknown option " + option);
}
i += 2;
@@ -2580,10 +2511,10 @@ public class MIRACore {
if (!canRunCommand && !canRunJoshua) { // can only run fake decoder
if (!canRunFake) {
- println("MIRA cannot decode; must provide one of: command file (for external decoder),");
- println(" source file (for Joshua decoder),");
- println(" or prefix for existing output files (for fake decoder).");
- System.exit(12);
+ String msg = "MIRA cannot decode; must provide one of: command file (for external decoder),"
+ + " source file (for Joshua decoder),"
+ + " or prefix for existing output files (for fake decoder).";
+ throw new RuntimeException(msg);
}
int lastGoodIt = 0;
@@ -2596,9 +2527,8 @@ public class MIRACore {
}
if (lastGoodIt == 0) {
- println("Fake decoder cannot find first output file "
+ throw new RuntimeException("Fake decoder cannot find first output file "
+ (fakeFileNamePrefix + 1 + fakeFileNameSuffix));
- System.exit(13);
} else if (lastGoodIt < maxMERTIterations) {
if (firstTime)
println("Warning: can only run fake decoder; existing output files "
@@ -2690,8 +2620,7 @@ public class MIRACore {
private void checkFile(String fileName) {
if (!fileExists(fileName)) {
- println("The file " + fileName + " was not found!");
- System.exit(40);
+ throw new RuntimeException("The file " + fileName + " was not found!");
}
}
@@ -2726,8 +2655,7 @@ public class MIRACore {
deleteFile(inputFileName);
} catch (IOException e) {
- System.err.println("IOException in MIRACore.gzipFile(String,String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2759,8 +2687,7 @@ public class MIRACore {
deleteFile(gzippedFileName);
} catch (IOException e) {
- System.err.println("IOException in MIRACore.gunzipFile(String,String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2776,8 +2703,7 @@ public class MIRACore {
if (!checker.exists()) {
checker = new File(prefix + ".1");
if (!checker.exists()) {
- println("Can't find reference files.");
- System.exit(50);
+ throw new RuntimeException("Can't find reference files.");
} else {
prefix = prefix + ".";
}
@@ -2806,8 +2732,7 @@ public class MIRACore {
for (int r = 0; r < numFiles; ++r) {
if (countLines(prefix + nextIndex) != lineCount) {
- println("Line count mismatch in " + (prefix + nextIndex) + ".");
- System.exit(60);
+ throw new RuntimeException("Line count mismatch in " + (prefix + nextIndex) + ".");
}
InputStream inStream = new FileInputStream(new File(prefix + nextIndex));
inFile[r] = new BufferedReader(new InputStreamReader(inStream, "utf8"));
@@ -2828,14 +2753,8 @@ public class MIRACore {
for (int r = 0; r < numFiles; ++r) {
inFile[r].close();
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MIRACore.createUnifiedRefFile(String,int): "
- + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MIRACore.createUnifiedRefFile(String,int): "
- + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return outFileName;
@@ -2988,8 +2907,7 @@ public class MIRACore {
inFile.close();
} catch (IOException e) {
- System.err.println("IOException in MIRACore.countLines(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return count;
@@ -3010,8 +2928,7 @@ public class MIRACore {
inFile.close();
} catch (IOException e) {
- System.err.println("IOException in MIRACore.countNonEmptyLines(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return count;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/pro/ClassifierMegaM.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/pro/ClassifierMegaM.java b/src/main/java/org/apache/joshua/pro/ClassifierMegaM.java
index 4817290..f75605f 100755
--- a/src/main/java/org/apache/joshua/pro/ClassifierMegaM.java
+++ b/src/main/java/org/apache/joshua/pro/ClassifierMegaM.java
@@ -72,8 +72,7 @@ public class ClassifierMegaM implements ClassifierInterface {
int decStatus = p.waitFor();
if (decStatus != 0) {
- System.out.println("Call to decoder returned " + decStatus + "; was expecting " + 0 + ".");
- System.exit(30);
+ throw new RuntimeException("Call to decoder returned " + decStatus + "; was expecting " + 0 + ".");
}
// read the weights
@@ -86,11 +85,8 @@ public class ClassifierMegaM implements ClassifierInterface {
file.delete();
file = new File(weightFilePath);
file.delete();
- } catch (IOException exception) {
- exception.getStackTrace();
- } catch (InterruptedException e) {
- System.err.println("InterruptedException in MertCore.run_decoder(int): " + e.getMessage());
- System.exit(99903);;
+ } catch (IOException | InterruptedException e) {
+ throw new RuntimeException(e);
}
System.out.println("------- MegaM training ends ------");
@@ -111,8 +107,7 @@ public class ClassifierMegaM implements ClassifierInterface {
*/
public void setClassifierParam(String[] param) {
if (param == null) {
- System.out.println("ERROR: must provide parameters for MegaM classifier!");
- System.exit(10);
+ throw new RuntimeException("ERROR: must provide parameters for MegaM classifier!");
} else {
commandFilePath = param[0];
trainingFilePath = param[1];
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/pro/ClassifierSVM.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/pro/ClassifierSVM.java b/src/main/java/org/apache/joshua/pro/ClassifierSVM.java
index a1fe91a..5c1f4e3 100755
--- a/src/main/java/org/apache/joshua/pro/ClassifierSVM.java
+++ b/src/main/java/org/apache/joshua/pro/ClassifierSVM.java
@@ -73,8 +73,8 @@ public class ClassifierSVM implements ClassifierInterface {
int decStatus = p.waitFor();
if (decStatus != 0) {
- System.out.println("Call to decoder returned " + decStatus + "; was expecting " + 0 + ".");
- System.exit(30);
+ throw new RuntimeException("Call to decoder returned " + decStatus + "; was expecting "
+ + 0 + ".");
}
// read the model file
@@ -109,11 +109,8 @@ public class ClassifierSVM implements ClassifierInterface {
file.delete();
file = new File(modelFilePath);
file.delete();
- } catch (IOException exception) {
- exception.getStackTrace();
- } catch (InterruptedException e) {
- System.err.println("InterruptedException in MertCore.run_decoder(int): " + e.getMessage());
- System.exit(99903);;
+ } catch (IOException | InterruptedException e) {
+ throw new RuntimeException(e);
}
System.out.println("------- SVM training ends ------");
@@ -129,8 +126,7 @@ public class ClassifierSVM implements ClassifierInterface {
*/
public void setClassifierParam(String[] param) {
if (param == null) {
- System.out.println("ERROR: must provide parameters for LibSVM classifier!");
- System.exit(10);
+ throw new RuntimeException("ERROR: must provide parameters for LibSVM classifier!");
} else {
commandFilePath = param[0];
trainingFilePath = param[1];
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/pro/Optimizer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/pro/Optimizer.java b/src/main/java/org/apache/joshua/pro/Optimizer.java
index ff7d902..ad80305 100755
--- a/src/main/java/org/apache/joshua/pro/Optimizer.java
+++ b/src/main/java/org/apache/joshua/pro/Optimizer.java
@@ -99,18 +99,9 @@ public class Optimizer {
// System.out.println(output);
return finalLambda;
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- System.exit(50);
- } catch (InstantiationException e) {
- e.printStackTrace();
- System.exit(55);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- System.exit(60);
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
+ throw new RuntimeException(e);
}
-
- return null;
}
public double computeCorpusMetricScore(double[] finalLambda) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/pro/PROCore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/pro/PROCore.java b/src/main/java/org/apache/joshua/pro/PROCore.java
index e378e9d..24bee52 100755
--- a/src/main/java/org/apache/joshua/pro/PROCore.java
+++ b/src/main/java/org/apache/joshua/pro/PROCore.java
@@ -320,12 +320,8 @@ public class PROCore {
}
inFile_names.close();
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in PROCore.initialize(int): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in PROCore.initialize(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
// the parameter file contains one line per parameter
@@ -383,12 +379,8 @@ public class PROCore {
inFile_comm.close();
}
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in PROCore.initialize(int): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in PROCore.initialize(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
// set static data members for the EvaluationMetric class
@@ -1465,16 +1457,11 @@ public class PROCore {
int decStatus = p.waitFor();
if (decStatus != validDecoderExitValue) {
- println("Call to decoder returned " + decStatus + "; was expecting "
+ throw new RuntimeException("Call to decoder returned " + decStatus + "; was expecting "
+ validDecoderExitValue + ".");
- System.exit(30);
}
- } catch (IOException e) {
- System.err.println("IOException in PROCore.run_decoder(int): " + e.getMessage());
- System.exit(99902);
- } catch (InterruptedException e) {
- System.err.println("InterruptedException in PROCore.run_decoder(int): " + e.getMessage());
- System.exit(99903);
+ } catch (IOException | InterruptedException e) {
+ throw new RuntimeException(e);
}
retSA[0] = decoderOutFileName;
@@ -1572,13 +1559,8 @@ public class PROCore {
gzipFile(featsFileName);
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in PROCore.produceTempFiles(int): "
- + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in PROCore.produceTempFiles(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -1626,9 +1608,7 @@ public class PROCore {
inFile.close();
outFile.close();
} catch (IOException e) {
- System.err.println("IOException in PROCore.createConfigFile(double[],String,String): "
- + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -1638,8 +1618,7 @@ public class PROCore {
try {
inFile_init = new Scanner(new FileReader(paramsFileName));
} catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in PROCore.processParamFile(): " + e.getMessage());
- System.exit(99901);
+ throw new RuntimeException(e);
}
String dummy = "";
@@ -1662,8 +1641,7 @@ public class PROCore {
} else if (dummy.equals("Fix")) {
isOptimizable[c] = false;
} else {
- println("Unknown isOptimizable string " + dummy + " (must be either Opt or Fix)");
- System.exit(21);
+ throw new RuntimeException("Unknown isOptimizable string " + dummy + " (must be either Opt or Fix)");
}
if (!isOptimizable[c]) { // skip next two values
@@ -1678,25 +1656,22 @@ public class PROCore {
// set minRandValue[c] and maxRandValue[c] (range for random values)
dummy = inFile_init.next();
if (dummy.equals("-Inf") || dummy.equals("+Inf")) {
- println("minRandValue[" + c + "] cannot be -Inf or +Inf!");
- System.exit(21);
+ throw new RuntimeException("minRandValue[" + c + "] cannot be -Inf or +Inf!");
} else {
minRandValue[c] = Double.parseDouble(dummy);
}
dummy = inFile_init.next();
if (dummy.equals("-Inf") || dummy.equals("+Inf")) {
- println("maxRandValue[" + c + "] cannot be -Inf or +Inf!");
- System.exit(21);
+ throw new RuntimeException("maxRandValue[" + c + "] cannot be -Inf or +Inf!");
} else {
maxRandValue[c] = Double.parseDouble(dummy);
}
// check for illogical values
if (minRandValue[c] > maxRandValue[c]) {
- println("minRandValue[" + c + "]=" + minRandValue[c] + " > " + maxRandValue[c]
+ throw new RuntimeException("minRandValue[" + c + "]=" + minRandValue[c] + " > " + maxRandValue[c]
+ "=maxRandValue[" + c + "]!");
- System.exit(21);
}
// check for odd values
@@ -1747,40 +1722,34 @@ public class PROCore {
normalizationOptions[2] = Vocabulary.id(pName);
if (normalizationOptions[1] <= 0) {
- println("Value for the absval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the absval normalization method must be positive.");
}
if (normalizationOptions[2] == 0) {
- println("Unrecognized feature name " + normalizationOptions[2]
- + " for absval normalization method.", 1);
- System.exit(21);
+ throw new RuntimeException("Unrecognized feature name " + normalizationOptions[2]
+ + " for absval normalization method.");
}
} else if (dummyA[0].equals("maxabsval")) {
normalizationOptions[0] = 2;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
if (normalizationOptions[1] <= 0) {
- println("Value for the maxabsval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the maxabsval normalization method must be positive.");
}
} else if (dummyA[0].equals("minabsval")) {
normalizationOptions[0] = 3;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
if (normalizationOptions[1] <= 0) {
- println("Value for the minabsval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the minabsval normalization method must be positive.");
}
} else if (dummyA[0].equals("LNorm")) {
normalizationOptions[0] = 4;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
normalizationOptions[2] = Double.parseDouble(dummyA[2]);
if (normalizationOptions[1] <= 0 || normalizationOptions[2] <= 0) {
- println("Both values for the LNorm normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Both values for the LNorm normalization method must be positive.");
}
} else {
- println("Unrecognized normalization method " + dummyA[0] + "; "
+ throw new RuntimeException("Unrecognized normalization method " + dummyA[0] + "; "
+ "must be one of none, absval, maxabsval, and LNorm.");
- System.exit(21);
} // if (dummyA[0])
inFile_init.close();
@@ -1892,12 +1861,8 @@ public class PROCore {
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in PROCore.processDocInfo(): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in PROCore.processDocInfo(): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -1998,8 +1963,7 @@ public class PROCore {
outFile_lambdas.close();
} catch (IOException e) {
- System.err.println("IOException in PROCore.finish(): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2080,9 +2044,7 @@ public class PROCore {
argsVector.add(paramA[opt]);
}
} else {
- println("Malformed line in config file:");
- println(origLine);
- System.exit(70);
+ throw new RuntimeException("Malformed line in config file:" + origLine);
}
}
@@ -2091,12 +2053,9 @@ public class PROCore {
inFile.close();
} catch (FileNotFoundException e) {
println("PRO configuration file " + fileName + " was not found!");
- System.err.println("FileNotFoundException in PROCore.cfgFileToArgsArray(String): "
- + e.getMessage());
- System.exit(99901);
+ throw new RuntimeException(e);
} catch (IOException e) {
- System.err.println("IOException in PROCore.cfgFileToArgsArray(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
String[] argsArray = new String[argsVector.size()];
@@ -2174,14 +2133,12 @@ public class PROCore {
} else if (option.equals("-rps")) {
refsPerSen = Integer.parseInt(args[i + 1]);
if (refsPerSen < 1) {
- println("refsPerSen must be positive.");
- System.exit(10);
+ throw new RuntimeException("refsPerSen must be positive.");
}
} else if (option.equals("-txtNrm")) {
textNormMethod = Integer.parseInt(args[i + 1]);
if (textNormMethod < 0 || textNormMethod > 4) {
- println("textNormMethod should be between 0 and 4");
- System.exit(10);
+ throw new RuntimeException("textNormMethod should be between 0 and 4");
}
} else if (option.equals("-p")) {
paramsFileName = args[i + 1];
@@ -2201,8 +2158,7 @@ public class PROCore {
}
i += optionCount;
} else {
- println("Unknown metric name " + metricName + ".");
- System.exit(10);
+ throw new RuntimeException("Unknown metric name " + metricName + ".");
}
} else if (option.equals("-docSet")) {
String method = args[i + 1];
@@ -2247,32 +2203,27 @@ public class PROCore {
docSubsetInfo[6] = Integer.parseInt(a2);
i += 3;
} else {
- println("Unknown docSet method " + method + ".");
- System.exit(10);
+ throw new RuntimeException("Unknown docSet method " + method + ".");
}
} else if (option.equals("-maxIt")) {
maxMERTIterations = Integer.parseInt(args[i + 1]);
if (maxMERTIterations < 1) {
- println("maxMERTIts must be positive.");
- System.exit(10);
+ throw new RuntimeException("maxMERTIts must be positive.");
}
} else if (option.equals("-minIt")) {
minMERTIterations = Integer.parseInt(args[i + 1]);
if (minMERTIterations < 1) {
- println("minMERTIts must be positive.");
- System.exit(10);
+ throw new RuntimeException("minMERTIts must be positive.");
}
} else if (option.equals("-prevIt")) {
prevMERTIterations = Integer.parseInt(args[i + 1]);
if (prevMERTIterations < 0) {
- println("prevMERTIts must be non-negative.");
- System.exit(10);
+ throw new RuntimeException("prevMERTIts must be non-negative.");
}
} else if (option.equals("-stopIt")) {
stopMinIts = Integer.parseInt(args[i + 1]);
if (stopMinIts < 1) {
- println("stopMinIts must be positive.");
- System.exit(10);
+ throw new RuntimeException("stopMinIts must be positive.");
}
} else if (option.equals("-stopSig")) {
stopSigValue = Double.parseDouble(args[i + 1]);
@@ -2283,20 +2234,17 @@ public class PROCore {
else if (option.equals("-thrCnt")) {
numOptThreads = Integer.parseInt(args[i + 1]);
if (numOptThreads < 1) {
- println("threadCount must be positive.");
- System.exit(10);
+ throw new RuntimeException("threadCount must be positive.");
}
} else if (option.equals("-save")) {
saveInterFiles = Integer.parseInt(args[i + 1]);
if (saveInterFiles < 0 || saveInterFiles > 3) {
- println("save should be between 0 and 3");
- System.exit(10);
+ throw new RuntimeException("save should be between 0 and 3");
}
} else if (option.equals("-compress")) {
compressFiles = Integer.parseInt(args[i + 1]);
if (compressFiles < 0 || compressFiles > 1) {
- println("compressFiles should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("compressFiles should be either 0 or 1");
}
} else if (option.equals("-opi")) {
int opi = Integer.parseInt(args[i + 1]);
@@ -2305,8 +2253,7 @@ public class PROCore {
} else if (opi == 0) {
oneModificationPerIteration = false;
} else {
- println("oncePerIt must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("oncePerIt must be either 0 or 1.");
}
} else if (option.equals("-rand")) {
int rand = Integer.parseInt(args[i + 1]);
@@ -2315,8 +2262,7 @@ public class PROCore {
} else if (rand == 0) {
randInit = false;
} else {
- println("randInit must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("randInit must be either 0 or 1.");
}
} else if (option.equals("-seed")) {
if (args[i + 1].equals("time")) {
@@ -2355,8 +2301,7 @@ public class PROCore {
else if (retBest == 0)
returnBest = false;
else {
- println("-returnBest must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-returnBest must be either 0 or 1.");
}
}
// interpolation coefficient between current & previous weights
@@ -2374,8 +2319,7 @@ public class PROCore {
} else if (option.equals("-passIt")) {
int val = Integer.parseInt(args[i + 1]);
if (val < 0 || val > 1) {
- println("passIterationToDecoder should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("passIterationToDecoder should be either 0 or 1");
}
passIterationToDecoder = (val == 1) ? true : false;
} else if (option.equals("-decOut")) {
@@ -2387,35 +2331,30 @@ public class PROCore {
} else if (option.equals("-N")) {
sizeOfNBest = Integer.parseInt(args[i + 1]);
if (sizeOfNBest < 1) {
- println("N must be positive.");
- System.exit(10);
+ throw new RuntimeException("N must be positive.");
}
}
// Output specs
else if (option.equals("-v")) {
verbosity = Integer.parseInt(args[i + 1]);
if (verbosity < 0 || verbosity > 4) {
- println("verbosity should be between 0 and 4");
- System.exit(10);
+ throw new RuntimeException("verbosity should be between 0 and 4");
}
} else if (option.equals("-decV")) {
decVerbosity = Integer.parseInt(args[i + 1]);
if (decVerbosity < 0 || decVerbosity > 1) {
- println("decVerbosity should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("decVerbosity should be either 0 or 1");
}
} else if (option.equals("-fake")) {
fakeFileNameTemplate = args[i + 1];
int QM_i = fakeFileNameTemplate.indexOf("?");
if (QM_i <= 0) {
- println("fakeFileNameTemplate must contain '?' to indicate position of iteration number");
- System.exit(10);
+ throw new RuntimeException("fakeFileNameTemplate must contain '?' to indicate position of iteration number");
}
fakeFileNamePrefix = fakeFileNameTemplate.substring(0, QM_i);
fakeFileNameSuffix = fakeFileNameTemplate.substring(QM_i + 1);
} else {
- println("Unknown option " + option);
- System.exit(10);
+ throw new RuntimeException("Unknown option " + option);
}
i += 2;
@@ -2487,10 +2426,10 @@ public class PROCore {
if (!canRunCommand && !canRunJoshua) { // can only run fake decoder
if (!canRunFake) {
- println("PRO cannot decode; must provide one of: command file (for external decoder),");
- println(" source file (for Joshua decoder),");
- println(" or prefix for existing output files (for fake decoder).");
- System.exit(12);
+ String msg = "PRO cannot decode; must provide one of: command file (for external decoder),"
+ + " source file (for Joshua decoder), or prefix for existing output files "
+ + "(for fake decoder).";
+ throw new RuntimeException(msg);
}
int lastGoodIt = 0;
@@ -2503,9 +2442,8 @@ public class PROCore {
}
if (lastGoodIt == 0) {
- println("Fake decoder cannot find first output file "
+ throw new RuntimeException("Fake decoder cannot find first output file "
+ (fakeFileNamePrefix + 1 + fakeFileNameSuffix));
- System.exit(13);
} else if (lastGoodIt < maxMERTIterations) {
if (firstTime)
println("Warning: can only run fake decoder; existing output files "
@@ -2597,8 +2535,7 @@ public class PROCore {
private void checkFile(String fileName) {
if (!fileExists(fileName)) {
- println("The file " + fileName + " was not found!");
- System.exit(40);
+ throw new RuntimeException("The file " + fileName + " was not found!");
}
}
@@ -2633,8 +2570,7 @@ public class PROCore {
deleteFile(inputFileName);
} catch (IOException e) {
- System.err.println("IOException in PROCore.gzipFile(String,String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2666,8 +2602,7 @@ public class PROCore {
deleteFile(gzippedFileName);
} catch (IOException e) {
- System.err.println("IOException in PROCore.gunzipFile(String,String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2683,8 +2618,7 @@ public class PROCore {
if (!checker.exists()) {
checker = new File(prefix + ".1");
if (!checker.exists()) {
- println("Can't find reference files.");
- System.exit(50);
+ throw new RuntimeException("Can't find reference files.");
} else {
prefix = prefix + ".";
}
@@ -2713,8 +2647,7 @@ public class PROCore {
for (int r = 0; r < numFiles; ++r) {
if (countLines(prefix + nextIndex) != lineCount) {
- println("Line count mismatch in " + (prefix + nextIndex) + ".");
- System.exit(60);
+ throw new RuntimeException("Line count mismatch in " + (prefix + nextIndex) + ".");
}
InputStream inStream = new FileInputStream(new File(prefix + nextIndex));
inFile[r] = new BufferedReader(new InputStreamReader(inStream, "utf8"));
@@ -2735,14 +2668,8 @@ public class PROCore {
for (int r = 0; r < numFiles; ++r) {
inFile[r].close();
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in PROCore.createUnifiedRefFile(String,int): "
- + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in PROCore.createUnifiedRefFile(String,int): "
- + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return outFileName;
@@ -2895,8 +2822,7 @@ public class PROCore {
inFile.close();
} catch (IOException e) {
- System.err.println("IOException in PROCore.countLines(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return count;
@@ -2917,8 +2843,7 @@ public class PROCore {
inFile.close();
} catch (IOException e) {
- System.err.println("IOException in PROCore.countNonEmptyLines(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return count;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/server/TcpServer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/server/TcpServer.java b/src/main/java/org/apache/joshua/server/TcpServer.java
index 137794d..36dc957 100644
--- a/src/main/java/org/apache/joshua/server/TcpServer.java
+++ b/src/main/java/org/apache/joshua/server/TcpServer.java
@@ -58,8 +58,8 @@ public class TcpServer {
serverSocket.close();
} catch (IOException e) {
- System.err.println(String.format("Could not listen on port: %d.", joshuaConfiguration.server_port));
- System.exit(-1);
+ throw new RuntimeException(String.format("Could not listen on port: %d.",
+ joshuaConfiguration.server_port));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/tools/GrammarPacker.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/tools/GrammarPacker.java b/src/main/java/org/apache/joshua/tools/GrammarPacker.java
index 0b5985d..d32ab53 100644
--- a/src/main/java/org/apache/joshua/tools/GrammarPacker.java
+++ b/src/main/java/org/apache/joshua/tools/GrammarPacker.java
@@ -104,8 +104,7 @@ public class GrammarPacker {
if (!packAlignments) {
logger.info("No alignments file or grammar specified, skipping.");
} else if (alignments != null && !new File(alignments_filename).exists()) {
- logger.severe("Alignments file does not exist: " + alignments);
- System.exit(1);
+ throw new RuntimeException("Alignments file does not exist: " + alignments);
}
if (config_filename != null) {
@@ -119,8 +118,7 @@ public class GrammarPacker {
File working_dir = new File(output);
working_dir.mkdir();
if (!working_dir.exists()) {
- logger.severe("Failed creating output directory.");
- System.exit(1);
+ throw new RuntimeException("Failed creating output directory.");
}
}
@@ -136,8 +134,7 @@ public class GrammarPacker {
String[] fields = line.split("[\\s]+");
if (fields.length < 2) {
- logger.severe("Incomplete line in config.");
- System.exit(1);
+ throw new RuntimeException("Incomplete line in config.");
}
if ("slice_size".equals(fields[0])) {
// Number of records to concurrently load into memory for sorting.
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/util/FileUtility.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/FileUtility.java b/src/main/java/org/apache/joshua/util/FileUtility.java
index db6e9d9..0c504f8 100644
--- a/src/main/java/org/apache/joshua/util/FileUtility.java
+++ b/src/main/java/org/apache/joshua/util/FileUtility.java
@@ -118,11 +118,8 @@ public class FileUtility {
File f1 = new File(srFile);
File f2 = new File(dtFile);
copyFile(f1, f2);
- } catch (FileNotFoundException ex) {
- System.out.println(ex.getMessage() + " in the specified directory.");
- System.exit(0);
} catch (IOException e) {
- System.out.println(e.getMessage());
+ throw new RuntimeException(e);
}
}
@@ -145,11 +142,8 @@ public class FileUtility {
in.close();
out.close();
System.out.println("File copied.");
- } catch (FileNotFoundException ex) {
- System.out.println(ex.getMessage() + " in the specified directory.");
- System.exit(0);
} catch (IOException e) {
- System.out.println(e.getMessage());
+ throw new RuntimeException(e);
}
}
@@ -227,8 +221,7 @@ public class FileUtility {
* Method to handle standard IO xceptions. catch (Exception e) {Utility.handleIO_exception(e);}
*/
public static void handleExceptions(Exception e) {
- e.printStackTrace();
- System.exit(-1);
+ throw new RuntimeException(e);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/util/JoshuaEval.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/JoshuaEval.java b/src/main/java/org/apache/joshua/util/JoshuaEval.java
index 2a0b44c..3171641 100644
--- a/src/main/java/org/apache/joshua/util/JoshuaEval.java
+++ b/src/main/java/org/apache/joshua/util/JoshuaEval.java
@@ -102,13 +102,11 @@ public class JoshuaEval {
// testIndex=candPerSen means last candidate should be evaluated
if (inFileFormat.equals("plain") && candPerSen < 1) {
- println("candPerSen must be positive for a file in plain format.");
- System.exit(30);
+ throw new RuntimeException("candPerSen must be positive for a file in plain format.");
}
if (inFileFormat.equals("plain") && (testIndex < 1 || testIndex > candPerSen)) {
- println("For the plain format, testIndex must be in [1,candPerSen]");
- System.exit(31);
+ throw new RuntimeException("For the plain format, testIndex must be in [1,candPerSen]");
}
@@ -170,8 +168,7 @@ public class JoshuaEval {
if (line == null) {
println("Not enough candidates in " + inFileName + " to extract the " + candRank
+ "'th candidate for each sentence.");
- println("(Failed to extract one for the " + i + "'th sentence (0-indexed).)");
- System.exit(32);
+ throw new RuntimeException("(Failed to extract one for the " + i + "'th sentence (0-indexed).)");
}
int read_i = Integer.parseInt(line.substring(0, line.indexOf(" |||")).trim());
@@ -188,30 +185,25 @@ public class JoshuaEval {
n = 1;
i += 1;
} else {
- println("Not enough candidates in " + inFileName + " to extract the " + candRank
- + "'th candidate for each sentence.");
- println("(Failed to extract one for the " + i + "'th sentence (0-indexed).)");
- System.exit(32);
+ String msg = "Not enough candidates in " + inFileName + " to extract the " + candRank
+ + "'th candidate for each sentence. (Failed to extract one for the "
+ + i + "'th sentence (0-indexed).)";
+ throw new RuntimeException(msg);
}
} // while (line != null)
if (i != numSentences) {
- println("Not enough candidates were found (i = " + i + "; was expecting " + numSentences
+ throw new RuntimeException("Not enough candidates were found (i = " + i + "; was expecting " + numSentences
+ ")");
- System.exit(33);
}
} // nbest format
inFile.close();
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MertCore.initialize(int): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MertCore.initialize(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
@@ -296,28 +288,24 @@ public class JoshuaEval {
} else if (option.equals("-format")) {
candFileFormat = args[argno + 1];
if (!candFileFormat.equals("plain") && !candFileFormat.equals("nbest")) {
- println("candFileFormat must be either plain or nbest.");
- System.exit(10);
+ throw new RuntimeException("candFileFormat must be either plain or nbest.");
}
} else if (option.equals("-rank")) {
candRank = Integer.parseInt(args[argno + 1]);
if (refsPerSen < 1) {
- println("Argument for -rank must be positive.");
- System.exit(10);
+ throw new RuntimeException("Argument for -rank must be positive.");
}
} else if (option.equals("-ref")) {
refFileName = args[argno + 1];
} else if (option.equals("-rps")) {
refsPerSen = Integer.parseInt(args[argno + 1]);
if (refsPerSen < 1) {
- println("refsPerSen must be positive.");
- System.exit(10);
+ throw new RuntimeException("refsPerSen must be positive.");
}
} else if (option.equals("-txtNrm")) {
textNormMethod = Integer.parseInt(args[argno + 1]);
if (textNormMethod < 0 || textNormMethod > 4) {
- println("textNormMethod should be between 0 and 4");
- System.exit(10);
+ throw new RuntimeException("textNormMethod should be between 0 and 4");
}
} else if (option.equals("-m")) {
metricName = args[argno + 1];
@@ -329,8 +317,7 @@ public class JoshuaEval {
}
argno += optionCount;
} else {
- println("Unknown metric name " + metricName + ".");
- System.exit(10);
+ throw new RuntimeException("Unknown metric name " + metricName + ".");
}
} else if (option.equals("-evr")) {
int evr = Integer.parseInt(args[argno + 1]);
@@ -339,8 +326,7 @@ public class JoshuaEval {
} else if (evr == 0) {
evaluateRefs = false;
} else {
- println("evalRefs must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("evalRefs must be either 0 or 1.");
}
} else if (option.equals("-v")) {
int v = Integer.parseInt(args[argno + 1]);
@@ -349,12 +335,10 @@ public class JoshuaEval {
} else if (v == 0) {
verbose = false;
} else {
- println("verbose must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("verbose must be either 0 or 1.");
}
} else {
- println("Unknown option " + option);
- System.exit(10);
+ throw new RuntimeException("Unknown option " + option);
}
argno += 2;
@@ -366,8 +350,7 @@ public class JoshuaEval {
if (! new File(refFile).exists())
refFile = refFileName + ".0";
if (! new File(refFile).exists()) {
- System.err.println(String.format("* FATAL: can't find first reference file '%s{0,.0}'", refFileName));
- System.exit(1);
+ throw new RuntimeException(String.format("* FATAL: can't find first reference file '%s{0,.0}'", refFileName));
}
numSentences = countLines(refFile);
@@ -390,8 +373,7 @@ public class JoshuaEval {
if (! new File(refFile).exists())
refFile = refFileName + "." + i;
if (! new File(refFile).exists()) {
- System.err.println(String.format("* FATAL: can't find reference file '%s'", refFile));
- System.exit(1);
+ throw new RuntimeException(String.format("* FATAL: can't find reference file '%s'", refFile));
}
reference_readers[i] = new BufferedReader(new InputStreamReader(new FileInputStream(new File(refFile)), "utf8"));
@@ -409,12 +391,8 @@ public class JoshuaEval {
for (int i = 0; i < refsPerSen; i++)
reference_readers[i].close();
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in JoshuaEval.processArgsAndInitialize(): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in JoshuaEval.processArgsAndInitialize(): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
// set static data members for the EvaluationMetric class
@@ -587,8 +565,7 @@ public class JoshuaEval {
inFile.close();
} catch (IOException e) {
- System.err.println("IOException in MertCore.countLines(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return count;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/util/SocketUtility.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/SocketUtility.java b/src/main/java/org/apache/joshua/util/SocketUtility.java
index 965a606..c3d923c 100644
--- a/src/main/java/org/apache/joshua/util/SocketUtility.java
+++ b/src/main/java/org/apache/joshua/util/SocketUtility.java
@@ -64,15 +64,8 @@ public class SocketUtility {
// res.data_out = new DataOutputStream(new BufferedOutputStream
// (res.socket.getOutputStream()));
- } catch (UnknownHostException e) {
- System.out.println("unknown host exception");
- System.exit(1);
- } catch (SocketTimeoutException e) {
- System.out.println("socket timeout exception");
- System.exit(1);
- } catch (IOException e) {
- System.out.println("io exception");
- System.exit(1);
+ } catch ( IOException e) {
+ throw new RuntimeException(e);
}
return res;
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/util/encoding/EncoderConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/encoding/EncoderConfiguration.java b/src/main/java/org/apache/joshua/util/encoding/EncoderConfiguration.java
index 5f71f90..df729ed 100644
--- a/src/main/java/org/apache/joshua/util/encoding/EncoderConfiguration.java
+++ b/src/main/java/org/apache/joshua/util/encoding/EncoderConfiguration.java
@@ -152,11 +152,9 @@ public class EncoderConfiguration {
}
} catch (ArrayIndexOutOfBoundsException e) {
- System.err.println("Usage: EncoderConfiguration <packed_directory>");
- System.exit(1);
+ throw new RuntimeException("Usage: EncoderConfiguration <packed_directory>");
} catch (IOException e) {
- System.err.println(String.format("* FATAL: can't find file %s/encoding", grammar_dir));
- System.exit(1);
+ throw new RuntimeException(String.format("* FATAL: can't find file %s/encoding", grammar_dir));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/util/encoding/FeatureTypeAnalyzer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/encoding/FeatureTypeAnalyzer.java b/src/main/java/org/apache/joshua/util/encoding/FeatureTypeAnalyzer.java
index f480ec1..9cf1cc4 100644
--- a/src/main/java/org/apache/joshua/util/encoding/FeatureTypeAnalyzer.java
+++ b/src/main/java/org/apache/joshua/util/encoding/FeatureTypeAnalyzer.java
@@ -74,8 +74,7 @@ public class FeatureTypeAnalyzer {
if ("encoder".equals(fields[0])) {
// Adding an encoder to the mix.
if (fields.length < 3) {
- logger.severe("Incomplete encoder line in config.");
- System.exit(0);
+ throw new RuntimeException("Incomplete encoder line in config.");
}
String encoder_key = fields[1];
ArrayList<Integer> feature_ids = new ArrayList<Integer>();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/zmert/IntermediateOptimizer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/zmert/IntermediateOptimizer.java b/src/main/java/org/apache/joshua/zmert/IntermediateOptimizer.java
index a22f9e7..333f937 100644
--- a/src/main/java/org/apache/joshua/zmert/IntermediateOptimizer.java
+++ b/src/main/java/org/apache/joshua/zmert/IntermediateOptimizer.java
@@ -613,12 +613,8 @@ public class IntermediateOptimizer implements Runnable {
inFile.close();
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in MertCore.initialize(int): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in MertCore.initialize(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
} // set_suffStats_array(HashMap[] suffStats_array, TreeSet[] indicesOfInterest, Vector[]
@@ -961,13 +957,7 @@ public class IntermediateOptimizer implements Runnable {
}
public void run() {
- try {
- real_run();
- } catch (Exception e) {
- System.err.println("Exception in IntermediateOptimizer.run(): " + e.getMessage());
- e.printStackTrace();
- System.exit(99905);
- }
+ real_run();
if (!strToPrint.equals("")) {
threadOutput.add(strToPrint);
}
[6/6] incubator-joshua git commit: Merge branch
'jar-with-dependencies' of https://github.com/thammegowda/incubator-joshua
into JOSHUA-264
Posted by mj...@apache.org.
Merge branch 'jar-with-dependencies' of https://github.com/thammegowda/incubator-joshua into JOSHUA-264
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/659e4646
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/659e4646
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/659e4646
Branch: refs/heads/JOSHUA-264
Commit: 659e464665254050a8f9ed321dcbdd08eef8a3d7
Parents: f354c29 575ca46
Author: Matt Post <po...@cs.jhu.edu>
Authored: Mon May 16 20:14:04 2016 -0400
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Mon May 16 20:14:04 2016 -0400
----------------------------------------------------------------------
pom.xml | 13 +++++++++++++
1 file changed, 13 insertions(+)
----------------------------------------------------------------------
[5/6] incubator-joshua git commit: Added Maven assembly plugin
Posted by mj...@apache.org.
Added Maven assembly plugin
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/575ca465
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/575ca465
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/575ca465
Branch: refs/heads/JOSHUA-264
Commit: 575ca465553f2cbc7de06b8c362a3bff71f44de7
Parents: 7c8e856
Author: Thamme Gowda <tg...@gmail.com>
Authored: Mon May 16 15:42:31 2016 -0700
Committer: Thamme Gowda <tg...@gmail.com>
Committed: Mon May 16 15:42:31 2016 -0700
----------------------------------------------------------------------
pom.xml | 13 +++++++++++++
1 file changed, 13 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/575ca465/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 740a677..3b1f4ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,6 +116,19 @@
<target>1.8</target>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.joshua.decoder.JoshuaDecoder</mainClass>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
</plugins>
</build>
<dependencies>
[3/6] incubator-joshua git commit: System.exit() removed and replaced
with RuntimeException(...)
Posted by mj...@apache.org.
System.exit() removed and replaced with RuntimeException(...)
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/9848541f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/9848541f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/9848541f
Branch: refs/heads/JOSHUA-264
Commit: 9848541f6cf52e7d316d1bacc565004c1bbc3128
Parents: 7c8e856
Author: Thamme Gowda <tg...@gmail.com>
Authored: Mon May 16 14:33:29 2016 -0700
Committer: Thamme Gowda <tg...@gmail.com>
Committed: Mon May 16 14:33:29 2016 -0700
----------------------------------------------------------------------
.../org/apache/joshua/adagrad/AdaGradCore.java | 225 ++++++-------------
.../org/apache/joshua/decoder/ArgsParser.java | 5 +-
.../java/org/apache/joshua/decoder/BLEU.java | 6 +-
.../java/org/apache/joshua/decoder/Decoder.java | 170 +++++++-------
.../joshua/decoder/JoshuaConfiguration.java | 109 +++++----
.../org/apache/joshua/decoder/Translation.java | 3 +-
.../apache/joshua/decoder/ff/TargetBigram.java | 50 ++---
.../decoder/ff/fragmentlm/FragmentLMFF.java | 5 +-
.../joshua/decoder/ff/fragmentlm/Tree.java | 9 +-
.../org/apache/joshua/decoder/ff/lm/KenLM.java | 6 +-
.../joshua/decoder/ff/lm/LanguageModelFF.java | 9 +-
.../ff/lm/StateMinimizingLanguageModel.java | 6 +-
.../ff/lm/berkeley_lm/LMGrammarBerkeley.java | 3 +-
.../joshua/decoder/ff/phrase/Distortion.java | 6 +-
.../joshua/decoder/hypergraph/HGNode.java | 4 +-
.../joshua/decoder/phrase/PhraseTable.java | 6 +-
.../joshua/decoder/segment_file/Sentence.java | 3 +-
.../java/org/apache/joshua/metrics/BLEU.java | 11 +-
.../apache/joshua/metrics/EvaluationMetric.java | 5 +-
.../apache/joshua/metrics/GradeLevelBLEU.java | 10 +-
.../java/org/apache/joshua/metrics/METEOR.java | 37 ++-
.../joshua/metrics/MinimumChangeBLEU.java | 7 +-
.../java/org/apache/joshua/metrics/Precis.java | 7 +-
.../joshua/metrics/PrecisMinusSourceBLEU.java | 6 +-
.../java/org/apache/joshua/metrics/TER.java | 60 ++---
.../org/apache/joshua/metrics/TERMinusBLEU.java | 6 +-
.../org/apache/joshua/metrics/TercomRunner.java | 11 +-
.../org/apache/joshua/metrics/ZeroOneLoss.java | 3 +-
.../java/org/apache/joshua/mira/MIRACore.java | 211 ++++++-----------
.../org/apache/joshua/pro/ClassifierMegaM.java | 13 +-
.../org/apache/joshua/pro/ClassifierSVM.java | 14 +-
.../java/org/apache/joshua/pro/Optimizer.java | 13 +-
.../java/org/apache/joshua/pro/PROCore.java | 189 +++++-----------
.../org/apache/joshua/server/TcpServer.java | 4 +-
.../org/apache/joshua/tools/GrammarPacker.java | 9 +-
.../org/apache/joshua/util/FileUtility.java | 13 +-
.../java/org/apache/joshua/util/JoshuaEval.java | 65 ++----
.../org/apache/joshua/util/SocketUtility.java | 11 +-
.../util/encoding/EncoderConfiguration.java | 6 +-
.../util/encoding/FeatureTypeAnalyzer.java | 3 +-
.../joshua/zmert/IntermediateOptimizer.java | 14 +-
.../java/org/apache/joshua/zmert/MertCore.java | 193 +++++-----------
42 files changed, 551 insertions(+), 995 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/adagrad/AdaGradCore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/adagrad/AdaGradCore.java b/src/main/java/org/apache/joshua/adagrad/AdaGradCore.java
index 5e4abbc..9601a74 100755
--- a/src/main/java/org/apache/joshua/adagrad/AdaGradCore.java
+++ b/src/main/java/org/apache/joshua/adagrad/AdaGradCore.java
@@ -329,12 +329,8 @@ public class AdaGradCore {
}
inFile_names.close();
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in AdaGradCore.initialize(int): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.initialize(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
// the parameter file contains one line per parameter
@@ -392,12 +388,8 @@ public class AdaGradCore {
inFile_comm.close();
}
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in AdaGradCore.initialize(int): " + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.initialize(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
// set static data members for the EvaluationMetric class
@@ -1221,13 +1213,8 @@ public class AdaGradCore {
println("Number of features observed so far: " + numParams);
println("", 1);
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in AdaGradCore.run_single_iteration(6): "
- + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.run_single_iteration(6): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
// n-best list converges
@@ -1501,17 +1488,11 @@ public class AdaGradCore {
int decStatus = p.waitFor();
if (decStatus != validDecoderExitValue) {
- println("Call to decoder returned " + decStatus + "; was expecting "
+ throw new RuntimeException("Call to decoder returned " + decStatus + "; was expecting "
+ validDecoderExitValue + ".");
- System.exit(30);
}
- } catch (IOException e) {
- System.err.println("IOException in AdaGradCore.run_decoder(int): " + e.getMessage());
- System.exit(99902);
- } catch (InterruptedException e) {
- System.err.println("InterruptedException in AdaGradCore.run_decoder(int): "
- + e.getMessage());
- System.exit(99903);
+ } catch (IOException | InterruptedException e) {
+ throw new RuntimeException(e);
}
retSA[0] = decoderOutFileName;
@@ -1609,13 +1590,8 @@ public class AdaGradCore {
gzipFile(featsFileName);
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in AdaGradCore.produceTempFiles(int): "
- + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.produceTempFiles(int): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -1663,9 +1639,7 @@ public class AdaGradCore {
inFile.close();
outFile.close();
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.createConfigFile(double[],String,String): "
- + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -1675,9 +1649,7 @@ public class AdaGradCore {
try {
inFile_init = new Scanner(new FileReader(paramsFileName));
} catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in AdaGradCore.processParamFile(): "
- + e.getMessage());
- System.exit(99901);
+ throw new RuntimeException(e);
}
String dummy = "";
@@ -1700,8 +1672,7 @@ public class AdaGradCore {
} else if (dummy.equals("Fix")) {
isOptimizable[c] = false;
} else {
- println("Unknown isOptimizable string " + dummy + " (must be either Opt or Fix)");
- System.exit(21);
+ throw new RuntimeException("Unknown isOptimizable string " + dummy + " (must be either Opt or Fix)");
}
if (!isOptimizable[c]) { // skip next two values
@@ -1716,25 +1687,22 @@ public class AdaGradCore {
// set minRandValue[c] and maxRandValue[c] (range for random values)
dummy = inFile_init.next();
if (dummy.equals("-Inf") || dummy.equals("+Inf")) {
- println("minRandValue[" + c + "] cannot be -Inf or +Inf!");
- System.exit(21);
+ throw new RuntimeException("minRandValue[" + c + "] cannot be -Inf or +Inf!");
} else {
minRandValue[c] = Double.parseDouble(dummy);
}
dummy = inFile_init.next();
if (dummy.equals("-Inf") || dummy.equals("+Inf")) {
- println("maxRandValue[" + c + "] cannot be -Inf or +Inf!");
- System.exit(21);
+ throw new RuntimeException("maxRandValue[" + c + "] cannot be -Inf or +Inf!");
} else {
maxRandValue[c] = Double.parseDouble(dummy);
}
// check for illogical values
if (minRandValue[c] > maxRandValue[c]) {
- println("minRandValue[" + c + "]=" + minRandValue[c] + " > " + maxRandValue[c]
+ throw new RuntimeException("minRandValue[" + c + "]=" + minRandValue[c] + " > " + maxRandValue[c]
+ "=maxRandValue[" + c + "]!");
- System.exit(21);
}
// check for odd values
@@ -1785,40 +1753,34 @@ public class AdaGradCore {
normalizationOptions[2] = Vocabulary.id(pName);
if (normalizationOptions[1] <= 0) {
- println("Value for the absval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the absval normalization method must be positive.");
}
if (normalizationOptions[2] == 0) {
- println("Unrecognized feature name " + normalizationOptions[2]
- + " for absval normalization method.", 1);
- System.exit(21);
+ throw new RuntimeException("Unrecognized feature name " + normalizationOptions[2]
+ + " for absval normalization method.");
}
} else if (dummyA[0].equals("maxabsval")) {
normalizationOptions[0] = 2;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
if (normalizationOptions[1] <= 0) {
- println("Value for the maxabsval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the maxabsval normalization method must be positive.");
}
} else if (dummyA[0].equals("minabsval")) {
normalizationOptions[0] = 3;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
if (normalizationOptions[1] <= 0) {
- println("Value for the minabsval normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Value for the minabsval normalization method must be positive.");
}
} else if (dummyA[0].equals("LNorm")) {
normalizationOptions[0] = 4;
normalizationOptions[1] = Double.parseDouble(dummyA[1]);
normalizationOptions[2] = Double.parseDouble(dummyA[2]);
if (normalizationOptions[1] <= 0 || normalizationOptions[2] <= 0) {
- println("Both values for the LNorm normalization method must be positive.");
- System.exit(21);
+ throw new RuntimeException("Both values for the LNorm normalization method must be positive.");
}
} else {
- println("Unrecognized normalization method " + dummyA[0] + "; "
+ throw new RuntimeException("Unrecognized normalization method " + dummyA[0] + "; "
+ "must be one of none, absval, maxabsval, and LNorm.");
- System.exit(21);
} // if (dummyA[0])
inFile_init.close();
@@ -1930,13 +1892,8 @@ public class AdaGradCore {
}
- } catch (FileNotFoundException e) {
- System.err.println("FileNotFoundException in AdaGradCore.processDocInfo(): "
- + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.processDocInfo(): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2037,8 +1994,7 @@ public class AdaGradCore {
outFile_lambdas.close();
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.finish(): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2119,9 +2075,8 @@ public class AdaGradCore {
argsVector.add(paramA[opt]);
}
} else {
- println("Malformed line in config file:");
- println(origLine);
- System.exit(70);
+ String msg = "Malformed line in config file:" + origLine;
+ throw new RuntimeException(msg);
}
}
@@ -2130,13 +2085,9 @@ public class AdaGradCore {
inFile.close();
} catch (FileNotFoundException e) {
println("AdaGrad configuration file " + fileName + " was not found!");
- System.err.println("FileNotFoundException in AdaGradCore.cfgFileToArgsArray(String): "
- + e.getMessage());
- System.exit(99901);
+ throw new RuntimeException(e);
} catch (IOException e) {
- System.err
- .println("IOException in AdaGradCore.cfgFileToArgsArray(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
String[] argsArray = new String[argsVector.size()];
@@ -2214,14 +2165,12 @@ public class AdaGradCore {
} else if (option.equals("-rps")) {
refsPerSen = Integer.parseInt(args[i + 1]);
if (refsPerSen < 1) {
- println("refsPerSen must be positive.");
- System.exit(10);
+ throw new RuntimeException("refsPerSen must be positive.");
}
} else if (option.equals("-txtNrm")) {
textNormMethod = Integer.parseInt(args[i + 1]);
if (textNormMethod < 0 || textNormMethod > 4) {
- println("textNormMethod should be between 0 and 4");
- System.exit(10);
+ throw new RuntimeException("textNormMethod should be between 0 and 4");
}
} else if (option.equals("-p")) {
paramsFileName = args[i + 1];
@@ -2241,8 +2190,7 @@ public class AdaGradCore {
}
i += optionCount;
} else {
- println("Unknown metric name " + metricName + ".");
- System.exit(10);
+ throw new RuntimeException("Unknown metric name " + metricName + ".");
}
} else if (option.equals("-docSet")) {
String method = args[i + 1];
@@ -2287,32 +2235,27 @@ public class AdaGradCore {
docSubsetInfo[6] = Integer.parseInt(a2);
i += 3;
} else {
- println("Unknown docSet method " + method + ".");
- System.exit(10);
+ throw new RuntimeException("Unknown docSet method " + method + ".");
}
} else if (option.equals("-maxIt")) {
maxMERTIterations = Integer.parseInt(args[i + 1]);
if (maxMERTIterations < 1) {
- println("maxIt must be positive.");
- System.exit(10);
+ throw new RuntimeException("maxIt must be positive.");
}
} else if (option.equals("-minIt")) {
minMERTIterations = Integer.parseInt(args[i + 1]);
if (minMERTIterations < 1) {
- println("minIt must be positive.");
- System.exit(10);
+ throw new RuntimeException("minIt must be positive.");
}
} else if (option.equals("-prevIt")) {
prevMERTIterations = Integer.parseInt(args[i + 1]);
if (prevMERTIterations < 0) {
- println("prevIt must be non-negative.");
- System.exit(10);
+ throw new RuntimeException("prevIt must be non-negative.");
}
} else if (option.equals("-stopIt")) {
stopMinIts = Integer.parseInt(args[i + 1]);
if (stopMinIts < 1) {
- println("stopIts must be positive.");
- System.exit(10);
+ throw new RuntimeException("stopIts must be positive.");
}
} else if (option.equals("-stopSig")) {
stopSigValue = Double.parseDouble(args[i + 1]);
@@ -2323,20 +2266,17 @@ public class AdaGradCore {
else if (option.equals("-thrCnt")) {
numOptThreads = Integer.parseInt(args[i + 1]);
if (numOptThreads < 1) {
- println("threadCount must be positive.");
- System.exit(10);
+ throw new RuntimeException("threadCount must be positive.");
}
} else if (option.equals("-save")) {
saveInterFiles = Integer.parseInt(args[i + 1]);
if (saveInterFiles < 0 || saveInterFiles > 3) {
- println("save should be between 0 and 3");
- System.exit(10);
+ throw new RuntimeException("save should be between 0 and 3");
}
} else if (option.equals("-compress")) {
compressFiles = Integer.parseInt(args[i + 1]);
if (compressFiles < 0 || compressFiles > 1) {
- println("compressFiles should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("compressFiles should be either 0 or 1");
}
} else if (option.equals("-opi")) {
int opi = Integer.parseInt(args[i + 1]);
@@ -2345,8 +2285,7 @@ public class AdaGradCore {
} else if (opi == 0) {
oneModificationPerIteration = false;
} else {
- println("oncePerIt must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("oncePerIt must be either 0 or 1.");
}
} else if (option.equals("-rand")) {
int rand = Integer.parseInt(args[i + 1]);
@@ -2355,8 +2294,7 @@ public class AdaGradCore {
} else if (rand == 0) {
randInit = false;
} else {
- println("randInit must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("randInit must be either 0 or 1.");
}
} else if (option.equals("-seed")) {
if (args[i + 1].equals("time")) {
@@ -2378,8 +2316,7 @@ public class AdaGradCore {
else if (shuffle == 0)
needShuffle = false;
else {
- println("-needShuffle must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-needShuffle must be either 0 or 1.");
}
}
// average weights after each epoch or not
@@ -2390,8 +2327,7 @@ public class AdaGradCore {
else if (avg == 0)
needAvg = false;
else {
- println("-needAvg must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-needAvg must be either 0 or 1.");
}
}
// return the best weight during tuning or not
@@ -2402,8 +2338,7 @@ public class AdaGradCore {
else if (retBest == 0)
returnBest = false;
else {
- println("-returnBest must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-returnBest must be either 0 or 1.");
}
}
// mini-batch size
@@ -2446,8 +2381,7 @@ public class AdaGradCore {
else if (option.equals("-scoreRatio")) {
scoreRatio = Double.parseDouble(args[i + 1]);
if (scoreRatio <= 0) {
- println("-scoreRatio must be positive");
- System.exit(10);
+ throw new RuntimeException("-scoreRatio must be positive");
}
} else if (option.equals("-needScaling")) {
int scale = Integer.parseInt(args[i + 1]);
@@ -2456,8 +2390,7 @@ public class AdaGradCore {
else if (scale == 0)
needScale = false;
else {
- println("-needScaling must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-needScaling must be either 0 or 1.");
}
} else if (option.equals("-usePseudoCorpus")) {
int use = Integer.parseInt(args[i + 1]);
@@ -2466,8 +2399,7 @@ public class AdaGradCore {
else if (use == 0)
usePseudoBleu = false;
else {
- println("-usePseudoCorpus must be either 0 or 1.");
- System.exit(10);
+ throw new RuntimeException("-usePseudoCorpus must be either 0 or 1.");
}
} else if (option.equals("-corpusDecay")) {
R = Double.parseDouble(args[i + 1]);
@@ -2479,8 +2411,7 @@ public class AdaGradCore {
} else if (option.equals("-passIt")) {
int val = Integer.parseInt(args[i + 1]);
if (val < 0 || val > 1) {
- println("passIterationToDecoder should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("passIterationToDecoder should be either 0 or 1");
}
passIterationToDecoder = (val == 1) ? true : false;
} else if (option.equals("-decOut")) {
@@ -2492,35 +2423,30 @@ public class AdaGradCore {
} else if (option.equals("-N")) {
sizeOfNBest = Integer.parseInt(args[i + 1]);
if (sizeOfNBest < 1) {
- println("N must be positive.");
- System.exit(10);
+ throw new RuntimeException("N must be positive.");
}
}
// Output specs
else if (option.equals("-v")) {
verbosity = Integer.parseInt(args[i + 1]);
if (verbosity < 0 || verbosity > 4) {
- println("verbosity should be between 0 and 4");
- System.exit(10);
+ throw new RuntimeException("verbosity should be between 0 and 4");
}
} else if (option.equals("-decV")) {
decVerbosity = Integer.parseInt(args[i + 1]);
if (decVerbosity < 0 || decVerbosity > 1) {
- println("decVerbosity should be either 0 or 1");
- System.exit(10);
+ throw new RuntimeException("decVerbosity should be either 0 or 1");
}
} else if (option.equals("-fake")) {
fakeFileNameTemplate = args[i + 1];
int QM_i = fakeFileNameTemplate.indexOf("?");
if (QM_i <= 0) {
- println("fakeFileNameTemplate must contain '?' to indicate position of iteration number");
- System.exit(10);
+ throw new RuntimeException("fakeFileNameTemplate must contain '?' to indicate position of iteration number");
}
fakeFileNamePrefix = fakeFileNameTemplate.substring(0, QM_i);
fakeFileNameSuffix = fakeFileNameTemplate.substring(QM_i + 1);
} else {
- println("Unknown option " + option);
- System.exit(10);
+ throw new RuntimeException("Unknown option " + option);
}
i += 2;
@@ -2592,10 +2518,11 @@ public class AdaGradCore {
if (!canRunCommand && !canRunJoshua) { // can only run fake decoder
if (!canRunFake) {
- println("AdaGrad cannot decode; must provide one of: command file (for external decoder),");
- println(" source file (for Joshua decoder),");
- println(" or prefix for existing output files (for fake decoder).");
- System.exit(12);
+ String msg = "AdaGrad cannot decode; must provide one of:"
+ + " command file (for external decoder),"
+ + " source file (for Joshua decoder),"
+ + " or prefix for existing output files (for fake decoder).";
+ throw new RuntimeException(msg);
}
int lastGoodIt = 0;
@@ -2608,9 +2535,8 @@ public class AdaGradCore {
}
if (lastGoodIt == 0) {
- println("Fake decoder cannot find first output file "
+ throw new RuntimeException("Fake decoder cannot find first output file "
+ (fakeFileNamePrefix + 1 + fakeFileNameSuffix));
- System.exit(13);
} else if (lastGoodIt < maxMERTIterations) {
if (firstTime)
println("Warning: can only run fake decoder; existing output files "
@@ -2702,8 +2628,7 @@ public class AdaGradCore {
private void checkFile(String fileName) {
if (!fileExists(fileName)) {
- println("The file " + fileName + " was not found!");
- System.exit(40);
+ throw new RuntimeException("The file " + fileName + " was not found!");
}
}
@@ -2738,8 +2663,7 @@ public class AdaGradCore {
deleteFile(inputFileName);
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.gzipFile(String,String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2771,8 +2695,7 @@ public class AdaGradCore {
deleteFile(gzippedFileName);
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.gunzipFile(String,String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
}
@@ -2788,8 +2711,8 @@ public class AdaGradCore {
if (!checker.exists()) {
checker = new File(prefix + ".1");
if (!checker.exists()) {
- println("Can't find reference files.");
- System.exit(50);
+ String msg = "Can't find reference files.";
+ throw new RuntimeException(msg);
} else {
prefix = prefix + ".";
}
@@ -2818,8 +2741,8 @@ public class AdaGradCore {
for (int r = 0; r < numFiles; ++r) {
if (countLines(prefix + nextIndex) != lineCount) {
- println("Line count mismatch in " + (prefix + nextIndex) + ".");
- System.exit(60);
+ String msg = "Line count mismatch in " + (prefix + nextIndex) + ".";
+ throw new RuntimeException(msg);
}
InputStream inStream = new FileInputStream(new File(prefix + nextIndex));
inFile[r] = new BufferedReader(new InputStreamReader(inStream, "utf8"));
@@ -2840,15 +2763,8 @@ public class AdaGradCore {
for (int r = 0; r < numFiles; ++r) {
inFile[r].close();
}
- } catch (FileNotFoundException e) {
- System.err
- .println("FileNotFoundException in AdaGradCore.createUnifiedRefFile(String,int): "
- + e.getMessage());
- System.exit(99901);
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.createUnifiedRefFile(String,int): "
- + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return outFileName;
@@ -3001,8 +2917,7 @@ public class AdaGradCore {
inFile.close();
} catch (IOException e) {
- System.err.println("IOException in AdaGradCore.countLines(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return count;
@@ -3023,9 +2938,7 @@ public class AdaGradCore {
inFile.close();
} catch (IOException e) {
- System.err
- .println("IOException in AdaGradCore.countNonEmptyLines(String): " + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException(e);
}
return count;
@@ -3157,8 +3070,8 @@ public class AdaGradCore {
randVal = randVal * sigma; // number in [-sigma,sigma]
randVal = randVal * origLambda[c]; // number in [-sigma*orig[c],sigma*orig[c]]
randVal = randVal + origLambda[c]; // number in
- // [orig[c]-sigma*orig[c],orig[c]+sigma*orig[c]]
- // = [orig[c]*(1-sigma),orig[c]*(1+sigma)]
+ // [orig[c]-sigma*orig[c],orig[c]+sigma*orig[c]]
+ // = [orig[c]*(1-sigma),orig[c]*(1+sigma)]
retLambda[c] = randVal;
} else {
retLambda[c] = origLambda[c];
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/ArgsParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ArgsParser.java b/src/main/java/org/apache/joshua/decoder/ArgsParser.java
index 016b0c5..fea20fc 100644
--- a/src/main/java/org/apache/joshua/decoder/ArgsParser.java
+++ b/src/main/java/org/apache/joshua/decoder/ArgsParser.java
@@ -71,7 +71,7 @@ public class ArgsParser {
System.out.println(line);
}
} catch (IOException e) {
- System.err.println("FATAL: missing license file!");
+ throw new RuntimeException("FATAL: missing license file!", e);
}
System.exit(0);
}
@@ -86,8 +86,7 @@ public class ArgsParser {
Decoder.LOG(1, "Parameters read from configuration file:");
joshuaConfiguration.readConfigFile(getConfigFile());
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new RuntimeException(e);
}
break;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/BLEU.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/BLEU.java b/src/main/java/org/apache/joshua/decoder/BLEU.java
index 43082a8..a531611 100644
--- a/src/main/java/org/apache/joshua/decoder/BLEU.java
+++ b/src/main/java/org/apache/joshua/decoder/BLEU.java
@@ -213,8 +213,7 @@ public class BLEU {
// sentence-bleu: BLEU= bp * prec; where prec = exp (sum 1/4 * log(prec[order]))
public static float computeBleu(int hypLen, float refLen, int[] numNgramMatch, int bleuOrder) {
if (hypLen <= 0 || refLen <= 0) {
- System.out.println("error: ref or hyp is zero len");
- System.exit(1);
+ throw new RuntimeException("error: ref or hyp is zero len");
}
float res = 0;
float wt = 1.0f / bleuOrder;
@@ -376,10 +375,9 @@ public class BLEU {
try {
ngramState = (NgramDPState) edge.getTailNodes().get(tailIndex).getDPState(0);
} catch (ClassCastException e) {
- System.err.println(String.format(
+ throw new RuntimeException(String.format(
"* FATAL: first state needs to be NgramDPState (found %s)", edge.getTailNodes()
.get(tailIndex).getDPState(0).getClass()));
- System.exit(1);
}
// Compute ngrams overlapping with left context of tail node
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/Decoder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/Decoder.java b/src/main/java/org/apache/joshua/decoder/Decoder.java
index 43f845c..1aac0b0 100644
--- a/src/main/java/org/apache/joshua/decoder/Decoder.java
+++ b/src/main/java/org/apache/joshua/decoder/Decoder.java
@@ -20,7 +20,7 @@ package org.apache.joshua.decoder;
import static org.apache.joshua.decoder.ff.FeatureVector.DENSE_FEATURE_NAMES;
-import java.io.BufferedWriter;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -62,7 +62,7 @@ import org.apache.joshua.util.io.LineReader;
/**
* This class handles decoder initialization and the complication introduced by multithreading.
- *
+ *
* After initialization, the main entry point to the Decoder object is
* decodeAll(TranslationRequest), which returns a set of Translation objects wrapped in an iterable
* Translations object. It is important that we support multithreading both (a) across the sentences
@@ -74,12 +74,12 @@ import org.apache.joshua.util.io.LineReader;
* parallelization by separating out reading the input stream from processing the translated sentences,
* but also ensures that round-robin parallelization occurs, since RequestParallelizer uses the
* thread pool before translating each request.
- *
+ *
* A decoding thread is handled by DecoderThread and launched from DecoderThreadRunner. The purpose
* of the runner is to record where to place the translated sentence when it is done (i.e., which
* Translations object). Translations itself is an iterator whose next() call blocks until the next
* translation is available.
- *
+ *
* @author Matt Post <po...@cs.jhu.edu>
* @author Zhifei Li, <zh...@gmail.com>
* @author wren ng thornton <wr...@users.sourceforge.net>
@@ -116,7 +116,7 @@ public class Decoder {
/**
* Constructor method that creates a new decoder using the specified configuration file.
- *
+ *
* @param configFile Name of configuration file.
*/
public Decoder(JoshuaConfiguration joshuaConfiguration, String configFile) {
@@ -126,7 +126,7 @@ public class Decoder {
/**
* Factory method that creates a new decoder using the specified configuration file.
- *
+ *
* @param configFile Name of configuration file.
*/
public static Decoder createDecoder(String configFile) {
@@ -168,9 +168,9 @@ public class Decoder {
* DecoderThreadRunner to translate it. Each call to decodeAll(TranslationRequest) launches a
* thread that will read the request's sentences, obtain a DecoderThread to translate them, and
* then place the Translation in the appropriate place.
- *
+ *
* @author Matt Post <po...@cs.jhu.edu>
- *
+ *
*/
private class RequestParallelizer extends Thread {
/* Source of sentences to translate. */
@@ -178,12 +178,12 @@ public class Decoder {
/* Where to put translated sentences. */
private final Translations response;
-
+
/* Sometimes we need to communicate with the client even when we didn't get a new sentence
* (e.g., metadata)
*/
private OutputStream out;
-
+
RequestParallelizer(TranslationRequestStream request, Translations response, OutputStream out) {
this.request = request;
this.response = response;
@@ -202,7 +202,7 @@ public class Decoder {
Sentence sentence = null;
try {
sentence = request.next();
-
+
} catch (MetaDataException meta) {
try {
handleMetadata(meta);
@@ -212,7 +212,7 @@ public class Decoder {
continue;
}
-
+
if (sentence == null) {
response.finish();
break;
@@ -227,7 +227,7 @@ public class Decoder {
/**
* When metadata is found on the input, it needs to be processed. That is done here. Sometimes
* this involves returning data to the client.
- *
+ *
* @param meta
* @throws IOException
*/
@@ -240,23 +240,23 @@ public class Decoder {
} else {
float old_weight = Decoder.weights.getWeight(tokens[1]);
Decoder.weights.set(tokens[1], Float.parseFloat(tokens[2]));
- System.err.println(String.format("@set_weight: %s %.3f -> %.3f",
+ System.err.println(String.format("@set_weight: %s %.3f -> %.3f",
tokens[1], old_weight,
Decoder.weights.getWeight(tokens[1])));
}
-
+
// TODO: return a JSON object with this weight or all weights
out.write("".getBytes());
} else if (meta.type().equals("get_weight")) {
// TODO: add to JSON object, send back
-
+
String[] tokens = meta.tokens();
-
+
System.err.println(String.format("%s = %f", tokens[1], Decoder.weights.getWeight(tokens[1])));
out.write("".getBytes());
-
+
} else if (meta.type().equals("add_rule")) {
String tokens[] = meta.tokens(" \\|\\|\\| ");
@@ -271,21 +271,21 @@ public class Decoder {
Decoder.this.customPhraseTable.addRule(rule);
rule.estimateRuleCost(featureFunctions);
Decoder.LOG(1, String.format("Added custom rule %s", formatRule(rule)));
-
+
String response = String.format("Added rule %s", formatRule(rule));
out.write(response.getBytes());
} else if (meta.type().equals("list_rules")) {
-
+
JSONMessage message = new JSONMessage();
-
+
// Walk the the grammar trie
ArrayList<Trie> nodes = new ArrayList<Trie>();
nodes.add(customPhraseTable.getTrieRoot());
-
+
while (nodes.size() > 0) {
Trie trie = nodes.remove(0);
-
+
if (trie == null)
continue;
@@ -298,9 +298,9 @@ public class Decoder {
if (trie.getExtensions() != null)
nodes.addAll(trie.getExtensions());
}
-
+
out.write(message.toString().getBytes());
-
+
} else if (meta.type().equals("remove_rule")) {
// Remove a rule from a custom grammar, if present
String[] tokens = meta.tokenString().split(" \\|\\|\\| ");
@@ -325,7 +325,7 @@ public class Decoder {
for (Rule rule: trie.getRuleCollection().getRules()) {
String target = rule.getEnglishWords();
target = target.substring(target.indexOf(' ') + 1);
-
+
if (tokens[1].equals(target)) {
matched = rule;
break;
@@ -335,14 +335,14 @@ public class Decoder {
out.write(String.format("Removed rule %s", formatRule(matched)).getBytes());
return;
}
-
+
out.write(String.format("No such rule %s", meta.tokenString()).getBytes());
}
}
/**
* Strips the nonterminals from the lefthand side of the rule.
- *
+ *
* @param rule
* @return
*/
@@ -354,7 +354,7 @@ public class Decoder {
ruleString += " " + Vocabulary.word(word);
first = false;
}
-
+
ruleString += " |||"; // space will get added with first English word
first = true;
for (int word: rule.getEnglish()) {
@@ -371,7 +371,7 @@ public class Decoder {
/**
* Retrieve a thread from the thread pool, blocking until one is available. The blocking occurs in
* a fair fashion (i.e,. FIFO across requests).
- *
+ *
* @return a thread that can be used for decoding.
*/
public DecoderThread getThread() {
@@ -389,11 +389,11 @@ public class Decoder {
* input Sentence, returning a Translation object when its done). This is done in a thread so as
* not to tie up the RequestHandler that launched it, freeing it to go on to the next sentence in
* the TranslationRequest, in turn permitting parallelization across the sentences of a request.
- *
+ *
* When the decoder thread is finshed, the Translation object is placed in the correct place in
* the corresponding Translations object that was returned to the caller of
* Decoder.decodeAll(TranslationRequest).
- *
+ *
* @author Matt Post <po...@cs.jhu.edu>
*/
private class DecoderThreadRunner extends Thread {
@@ -424,11 +424,9 @@ public class Decoder {
*/
threadPool.put(decoderThread);
} catch (Exception e) {
- System.err.println(String.format(
- "Input %d: FATAL UNCAUGHT EXCEPTION: %s", sentence.id(), e.getMessage()));
- e.printStackTrace();
- System.exit(1);;
-// translations.record(new Translation(sentence, null, featureFunctions, joshuaConfiguration));
+ throw new RuntimeException(String.format(
+ "Input %d: FATAL UNCAUGHT EXCEPTION: %s", sentence.id(), e.getMessage()), e);
+ // translations.record(new Translation(sentence, null, featureFunctions, joshuaConfiguration));
}
}
}
@@ -437,22 +435,22 @@ public class Decoder {
* This function is the main entry point into the decoder. It translates all the sentences in a
* (possibly boundless) set of input sentences. Each request launches its own thread to read the
* sentences of the request.
- *
+ *
* @param request
* @return an iterable set of Translation objects
- * @throws IOException
+ * @throws IOException
*/
public void decodeAll(TranslationRequestStream request, OutputStream out) throws IOException {
Translations translations = new Translations(request);
/* Start a thread to handle requests on the input stream */
new RequestParallelizer(request, translations, out).start();
-
+
// Create the n-best output stream
FileWriter nbest_out = null;
if (joshuaConfiguration.n_best_file != null)
nbest_out = new FileWriter(joshuaConfiguration.n_best_file);
-
+
for (;;) {
Translation translation = translations.next();
if (translation == null)
@@ -461,7 +459,7 @@ public class Decoder {
if (joshuaConfiguration.input_type == INPUT_TYPE.json || joshuaConfiguration.server_type == SERVER_TYPE.HTTP) {
JSONMessage message = JSONMessage.buildMessage(translation);
out.write(message.toString().getBytes());
-
+
} else {
/**
* We need to munge the feature value outputs in order to be compatible with Moses tuners.
@@ -475,12 +473,12 @@ public class Decoder {
// Write the complete formatted string to STDOUT
if (joshuaConfiguration.n_best_file != null)
nbest_out.write(text);
-
+
// Extract just the translation and output that to STDOUT
text = text.substring(0, text.indexOf('\n'));
String[] fields = text.split(" \\|\\|\\| ");
text = fields[1] + "\n";
-
+
} else {
text = translation.toString();
}
@@ -489,7 +487,7 @@ public class Decoder {
}
out.flush();
}
-
+
if (joshuaConfiguration.n_best_file != null)
nbest_out.close();
}
@@ -497,7 +495,7 @@ public class Decoder {
/**
* We can also just decode a single sentence.
- *
+ *
* @param sentence
* @return The translated sentence
*/
@@ -534,7 +532,7 @@ public class Decoder {
}
resetGlobalState();
}
-
+
public static void resetGlobalState() {
// clear/reset static variables
DENSE_FEATURE_NAMES.clear();
@@ -570,7 +568,7 @@ public class Decoder {
if (newDiscriminativeModel != null && "discriminative".equals(fds[0])) {
newSent.append(fds[0]).append(' ');
newSent.append(newDiscriminativeModel).append(' ');// change the
- // file name
+ // file name
for (int i = 2; i < fds.length - 1; i++) {
newSent.append(fds[i]).append(' ');
}
@@ -610,7 +608,7 @@ public class Decoder {
* Moses requires the pattern .*_.* for sparse features, and prohibits underscores in dense features.
* This conforms to that pattern. We assume non-conforming dense features start with tm_ or lm_,
* and the only sparse feature that needs converting is OOVPenalty.
- *
+ *
* @param feature
* @return the feature in Moses format
*/
@@ -619,13 +617,13 @@ public class Decoder {
if (feature.startsWith("tm_") || feature.startsWith("lm_"))
return feature.replace("_", "-");
}
-
+
return feature;
}
-
+
/**
* Initialize all parts of the JoshuaDecoder.
- *
+ *
* @param configFile File containing configuration options
* @return An initialized decoder
*/
@@ -646,10 +644,10 @@ public class Decoder {
for (int i = 0; i < tokens.length; i += 2) {
String feature = tokens[i];
float value = Float.parseFloat(tokens[i+1]);
-
+
if (joshuaConfiguration.moses)
feature = demoses(feature);
-
+
joshuaConfiguration.weights.add(String.format("%s %s", feature, tokens[i+1]));
Decoder.LOG(1, String.format("COMMAND LINE WEIGHT: %s -> %.3f", feature, value));
}
@@ -661,21 +659,20 @@ public class Decoder {
/* Sanity check for old-style unsupported feature invocations. */
if (pair.length != 2) {
- System.err.println("FATAL: Invalid feature weight line found in config file.");
- System.err
- .println(String.format("The line was '%s'", pairStr));
- System.err
- .println("You might be using an old version of the config file that is no longer supported");
- System.err
- .println("Check joshua-decoder.org or email joshua_support@googlegroups.com for help");
- System.exit(17);
+ StringBuilder errMsg = new StringBuilder();
+ errMsg.append("FATAL: Invalid feature weight line found in config file.\n");
+ errMsg.append(String.format("The line was '%s'\n", pairStr));
+ errMsg.append("You might be using an old version of the config file that is no longer supported\n");
+ errMsg.append("Check joshua-decoder.org or email joshua_support@googlegroups.com for help\n");
+ errMsg.append("Code = " + 17);
+ throw new RuntimeException(errMsg.toString());
}
weights.set(pair[0], Float.parseFloat(pair[1]));
}
Decoder.LOG(1, String.format("Read %d weights (%d of them dense)", weights.size(),
- DENSE_FEATURE_NAMES.size()));
+ DENSE_FEATURE_NAMES.size()));
// Do this before loading the grammars and the LM.
this.featureFunctions = new ArrayList<FeatureFunction>();
@@ -694,14 +691,14 @@ public class Decoder {
if (joshuaConfiguration.show_weights_and_quit) {
for (int i = 0; i < DENSE_FEATURE_NAMES.size(); i++) {
String name = DENSE_FEATURE_NAMES.get(i);
- if (joshuaConfiguration.moses)
+ if (joshuaConfiguration.moses)
System.out.println(String.format("%s= %.5f", mosesize(name), weights.getDense(i)));
else
System.out.println(String.format("%s %.5f", name, weights.getDense(i)));
}
System.exit(0);
}
-
+
// Sort the TM grammars (needed to do cube pruning)
if (joshuaConfiguration.amortized_sorting) {
Decoder.LOG(1, "Grammar sorting happening lazily on-demand.");
@@ -732,7 +729,7 @@ public class Decoder {
/**
* Initializes translation grammars Retained for backward compatibility
- *
+ *
* @param ownersSeen Records which PhraseModelFF's have been instantiated (one is needed for each
* owner)
* @throws IOException
@@ -763,19 +760,19 @@ public class Decoder {
packed_grammars.add(packed_grammar);
grammar = packed_grammar;
} catch (FileNotFoundException e) {
- System.err.println(String.format("Couldn't load packed grammar from '%s'", path));
- System.err.println("Perhaps it doesn't exist, or it may be an old packed file format.");
- System.exit(2);
+ String msg = String.format("Couldn't load packed grammar from '%s'", path)
+ + "Perhaps it doesn't exist, or it may be an old packed file format.";
+ throw new RuntimeException(e);
}
} else {
// thrax, hiero, samt
grammar = new MemoryBasedBatchGrammar(type, path, owner,
joshuaConfiguration.default_non_terminal, span_limit, joshuaConfiguration);
}
-
+
} else {
- int maxSourceLen = parsedArgs.containsKey("max-source-len")
+ int maxSourceLen = parsedArgs.containsKey("max-source-len")
? Integer.parseInt(parsedArgs.get("max-source-len"))
: -1;
@@ -831,11 +828,11 @@ public class Decoder {
ownersSeen.add(owner);
}
}
-
+
Decoder.LOG(1, String.format("Memory used %.1f MB",
((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000000.0)));
}
-
+
/**
* Checks if multiple packedGrammars have the same vocabulary by comparing their vocabulary file checksums.
*/
@@ -849,7 +846,7 @@ public class Decoder {
if (!checksum.equals(previous_checksum)) {
throw new RuntimeException(
"Trying to load multiple packed grammars with different vocabularies!" +
- "Have you packed them jointly?");
+ "Have you packed them jointly?");
}
previous_checksum = checksum;
}
@@ -881,7 +878,7 @@ public class Decoder {
String tokens[] = line.split("\\s+");
String feature = tokens[0];
Float value = Float.parseFloat(tokens[1]);
-
+
// Kludge for compatibility with Moses tuners
if (joshuaConfiguration.moses) {
feature = demoses(feature);
@@ -889,15 +886,9 @@ public class Decoder {
weights.increment(feature, value);
}
- } catch (FileNotFoundException ioe) {
- System.err.println("* FATAL: Can't find weights-file '" + fileName + "'");
- System.exit(1);
} catch (IOException ioe) {
- System.err.println("* FATAL: Can't read weights-file '" + fileName + "'");
- ioe.printStackTrace();
- System.exit(1);
+ throw new RuntimeException(ioe);
}
-
Decoder.LOG(1, String.format("Read %d weights from file '%s'", weights.size(), fileName));
}
@@ -913,16 +904,16 @@ public class Decoder {
/**
* Feature functions are instantiated with a line of the form
- *
+ *
* <pre>
* feature_function = FEATURE OPTIONS
* </pre>
- *
+ *
* Weights for features are listed separately.
- *
+ *
* @param tmOwnersSeen
* @throws IOException
- *
+ *
*/
private void initializeFeatureFunctions() throws IOException {
@@ -942,14 +933,13 @@ public class Decoder {
this.featureFunctions.add((FeatureFunction) constructor.newInstance(weights, fields, joshuaConfiguration));
} catch (Exception e) {
e.printStackTrace();
- System.err.println("* FATAL: could not find a feature '" + featureName + "'");
- System.exit(1);
+ throw new RuntimeException("* FATAL: could not find a feature '" + featureName + "'");
}
}
for (FeatureFunction feature : featureFunctions) {
Decoder.LOG(1, String.format("FEATURE: %s", feature.logString()));
-
+
}
weights.registerDenseFeatures(featureFunctions);
@@ -958,7 +948,7 @@ public class Decoder {
/**
* Searches a list of predefined paths for classes, and returns the first one found. Meant for
* instantiating feature functions.
- *
+ *
* @param name
* @return the class, found in one of the search paths
* @throws ClassNotFoundException
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/JoshuaConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/JoshuaConfiguration.java b/src/main/java/org/apache/joshua/decoder/JoshuaConfiguration.java
index bf8cfb3..b4624cf 100644
--- a/src/main/java/org/apache/joshua/decoder/JoshuaConfiguration.java
+++ b/src/main/java/org/apache/joshua/decoder/JoshuaConfiguration.java
@@ -39,23 +39,23 @@ import org.apache.joshua.util.io.LineReader;
/**
* Configuration file for Joshua decoder.
- *
+ *
* When adding new features to Joshua, any new configurable parameters should be added to this
* class.
- *
+ *
* @author Zhifei Li, <zh...@gmail.com>
* @author Matt Post <po...@cs.jhu.edu>
*/
public class JoshuaConfiguration {
-
+
// whether to construct a StructuredTranslation object for each request instead of
// printing to stdout. Used when the Decoder is used from Java directly.
public Boolean use_structured_output = false;
-
+
// If set to true, Joshua will lowercase the input, creating an annotation that marks the
// original case
public boolean lowercase = false;
-
+
// If set to true, Joshua will recapitalize the output by projecting the case from aligned
// source-side words
public boolean project_case = false;
@@ -89,7 +89,7 @@ public class JoshuaConfiguration {
*
* If this is empty, an unweighted default_non_terminal is used.
*/
-
+
public class OOVItem implements Comparable<OOVItem> {
public String label;
public float weight;
@@ -98,10 +98,10 @@ public class JoshuaConfiguration {
label = l;
weight = w;
}
-
+
@Override
public int compareTo(OOVItem other) {
- if (weight > other.weight)
+ if (weight > other.weight)
return -1;
else if (weight < other.weight)
return 1;
@@ -114,12 +114,12 @@ public class JoshuaConfiguration {
* Whether to segment OOVs into a lattice
*/
public boolean segment_oovs = false;
-
+
/*
* Enable lattice decoding.
*/
public boolean lattice_decoding = false;
-
+
/*
* If false, sorting of the complete grammar is done at load time. If true, grammar tries are not
* sorted till they are first accessed. Amortized sorting means you get your first translation
@@ -154,12 +154,12 @@ public class JoshuaConfiguration {
/* The number of hypotheses to output by default. */
public int topN = 1;
-
+
/**
* This string describes the format of each line of output from the decoder (i.e., the
* translations). The string can include arbitrary text and also variables. The following
* variables are available:
- *
+ *
* <pre>
* - %i the 0-indexed sentence number
* - %e the source string %s the translated sentence
@@ -204,7 +204,7 @@ public class JoshuaConfiguration {
/* Type of server. Not sure we need to keep the regular TCP one around. */
public enum SERVER_TYPE { none, TCP, HTTP };
public SERVER_TYPE server_type = SERVER_TYPE.TCP;
-
+
/* If set, Joshua will start a (multi-threaded, per "threads") TCP/IP server on this port. */
public int server_port = 0;
@@ -240,10 +240,10 @@ public class JoshuaConfiguration {
/* The search algorithm: currently either "cky" or "stack" */
public String search_algorithm = "cky";
-
+
/* The distortion limit */
public int reordering_limit = 8;
-
+
/* The number of target sides considered for each source side (after sorting by model weight) */
public int num_translation_options = 20;
@@ -251,16 +251,16 @@ public class JoshuaConfiguration {
* version of Sennrich (SSST 2014)
*/
public boolean use_dot_chart = true;
-
+
/* Moses compatibility */
public boolean moses = false;
-
+
/* If true, just print out the weights found in the config file, and exit. */
public boolean show_weights_and_quit = false;
-
+
/* Read input from a file (Moses compatible flag) */
public String input_file = null;
-
+
/* Write n-best output to this file */
public String n_best_file = null;
@@ -269,17 +269,17 @@ public class JoshuaConfiguration {
/* Weights overridden from the command line */
public String weight_overwrite = "";
-
+
/**
* This method resets the state of JoshuaConfiguration back to the state after initialization.
* This is useful when for example making different calls to the decoder within the same java
* program, which otherwise leads to potential errors due to inconsistent state as a result of
* loading the configuration multiple times without resetting etc.
- *
+ *
* This leads to the insight that in fact it may be an even better idea to refactor the code and
* make JoshuaConfiguration an object that is is created and passed as an argument, rather than a
* shared static object. This is just a suggestion for the next step.
- *
+ *
*/
public void reset() {
logger.info("Resetting the JoshuaConfiguration to its defaults ...");
@@ -289,7 +289,7 @@ public class JoshuaConfiguration {
tms = new ArrayList<String>();
weights_file = "";
default_non_terminal = "[X]";
- oovList = new ArrayList<OOVItem>();
+ oovList = new ArrayList<OOVItem>();
oovList.add(new OOVItem(default_non_terminal, 1.0f));
goal_symbol = "[GOAL]";
amortized_sorting = true;
@@ -311,7 +311,7 @@ public class JoshuaConfiguration {
features = new ArrayList<String>();
weights = new ArrayList<String>();
server_port = 0;
-
+
reordering_limit = 8;
num_translation_options = 20;
logger.info("...done");
@@ -353,8 +353,7 @@ public class JoshuaConfiguration {
tmpFile.delete();
} catch (IOException e) {
- e.printStackTrace();
- System.exit(1);
+ throw new RuntimeException(e);
}
}
@@ -364,7 +363,7 @@ public class JoshuaConfiguration {
try {
for (String line : configReader) {
line = line.trim(); // .toLowerCase();
-
+
if (Regex.commentOrEmptyLine.matches(line))
continue;
@@ -398,7 +397,7 @@ public class JoshuaConfiguration {
*
* feature-function = StateMinimizingLanguageModel -lm_order 5 -lm_file lm.gz
*/
-
+
String[] tokens = fds[1].split("\\s+");
if (tokens[2].equals("true"))
features.add(String.format("feature_function = StateMinimizingLanguageModel -lm_type kenlm -lm_order %s -lm_file %s",
@@ -414,14 +413,14 @@ public class JoshuaConfiguration {
* tm = TYPE -owner OWNER -maxspan MAXSPAN -path PATH
*/
String tmLine = fds[1];
-
+
String[] tokens = fds[1].split("\\s+");
if (! tokens[1].startsWith("-")) { // old format
tmLine = String.format("%s -owner %s -maxspan %s -path %s", tokens[0], tokens[1], tokens[2], tokens[3]);
Decoder.LOG(1, String.format("WARNING: Converting deprecated TM line from '%s' -> '%s'", fds[1], tmLine));
}
tms.add(tmLine);
-
+
} else if (parameter.equals("v")) {
Decoder.VERBOSE = Integer.parseInt(fds[1]);
@@ -446,7 +445,7 @@ public class JoshuaConfiguration {
String[] tokens = str.trim().split("\\s+");
oovList.add(new OOVItem(FormatUtils.markup(tokens[0]),
- (float) Math.log(Float.parseFloat(tokens[1]))));
+ (float) Math.log(Float.parseFloat(tokens[1]))));
str = br.readLine();
}
@@ -462,10 +461,8 @@ public class JoshuaConfiguration {
} else {
String[] tokens = fds[1].trim().split("\\s+");
if (tokens.length % 2 != 0) {
- System.err.println(String.format("* FATAL: invalid format for '%s'", fds[0]));
- System.exit(1);
- }
-
+ throw new RuntimeException(String.format("* FATAL: invalid format for '%s'", fds[0]));
+ }
oovList = new ArrayList<OOVItem>();
for (int i = 0; i < tokens.length; i += 2)
@@ -477,7 +474,7 @@ public class JoshuaConfiguration {
} else if (parameter.equals(normalize_key("lattice-decoding"))) {
lattice_decoding = true;
-
+
} else if (parameter.equals(normalize_key("segment-oovs"))) {
segment_oovs = true;
lattice_decoding = true;
@@ -542,13 +539,12 @@ public class JoshuaConfiguration {
logger.finest(String.format("pop-limit: %s", pop_limit));
} else if (parameter.equals(normalize_key("input-type"))) {
- if (fds[1].equals("json"))
+ if (fds[1].equals("json")) {
input_type = INPUT_TYPE.json;
- else if (fds[1].equals("plain"))
+ } else if (fds[1].equals("plain")) {
input_type = INPUT_TYPE.plain;
- else {
- System.err.println(String.format("* FATAL: invalid server type '%s'", fds[1]));
- System.exit(1);
+ } else {
+ throw new RuntimeException(String.format("* FATAL: invalid server type '%s'", fds[1]));
}
logger.info(String.format(" input-type: %s", input_type));
@@ -559,7 +555,7 @@ public class JoshuaConfiguration {
server_type = SERVER_TYPE.HTTP;
logger.info(String.format(" server-type: %s", server_type));
-
+
} else if (parameter.equals(normalize_key("server-port"))) {
server_port = Integer.parseInt(fds[1]);
logger.info(String.format(" server-port: %d", server_port));
@@ -597,16 +593,16 @@ public class JoshuaConfiguration {
fragmentMapFile = fds[1];
Tree.readMapping(fragmentMapFile);
- /** PHRASE-BASED PARAMETERS **/
+ /** PHRASE-BASED PARAMETERS **/
} else if (parameter.equals(normalize_key("search"))) {
search_algorithm = fds[1];
-
+
if (!search_algorithm.equals("cky") && !search_algorithm.equals("stack")) {
throw new RuntimeException(
"-search must be one of 'stack' (for phrase-based decoding) " +
- "or 'cky' (for hierarchical / syntactic decoding)");
+ "or 'cky' (for hierarchical / syntactic decoding)");
}
-
+
if (search_algorithm.equals("cky") && include_align_index) {
throw new RuntimeException(
"include_align_index is currently not supported with cky search");
@@ -617,13 +613,13 @@ public class JoshuaConfiguration {
} else if (parameter.equals(normalize_key("num-translation-options"))) {
num_translation_options = Integer.parseInt(fds[1]);
-
+
} else if (parameter.equals(normalize_key("no-dot-chart"))) {
use_dot_chart = false;
-
+
} else if (parameter.equals(normalize_key("moses"))) {
moses = true; // triggers some Moses-specific compatibility options
-
+
} else if (parameter.equals(normalize_key("show-weights"))) {
show_weights_and_quit = true;
@@ -637,23 +633,23 @@ public class JoshuaConfiguration {
} else if (parameter.equals(normalize_key("input-file"))) {
// for Moses compatibility
input_file = fds[1];
-
+
} else if (parameter.equals(normalize_key("weight-file"))) {
// for Moses, ignore
} else if (parameter.equals(normalize_key("weight-overwrite"))) {
weight_overwrite = fds[1];
-
+
} else if (parameter.equals(normalize_key("source-annotations"))) {
// Check source sentence
source_annotations = true;
} else if (parameter.equals(normalize_key("cached-rules-size"))) {
- // Check source sentence
- cachedRuleSize = Integer.parseInt(fds[1]);
+ // Check source sentence
+ cachedRuleSize = Integer.parseInt(fds[1]);
} else if (parameter.equals(normalize_key("lowercase"))) {
lowercase = true;
-
+
} else if (parameter.equals(normalize_key("project-case"))) {
project_case = true;
@@ -669,8 +665,7 @@ public class JoshuaConfiguration {
logger.warning(String.format("WARNING: ignoring deprecated parameter '%s'", fds[0]));
} else {
- logger.warning("FATAL: unknown configuration parameter '" + fds[0] + "'");
- System.exit(1);
+ throw new RuntimeException("FATAL: unknown configuration parameter '" + fds[0] + "'");
}
}
@@ -701,7 +696,7 @@ public class JoshuaConfiguration {
* equivalence classes on external use of parameter names, permitting arbitrary_under_scores and
* camelCasing in paramter names without forcing the user to memorize them all. Here are some
* examples of equivalent ways to refer to parameter names:
- *
+ *
* {pop-limit, poplimit, PopLimit, popLimit, pop_lim_it} {lmfile, lm-file, LM-FILE, lm_file}
*/
public static String normalize_key(String text) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/Translation.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/Translation.java b/src/main/java/org/apache/joshua/decoder/Translation.java
index 10852e5..5afae74 100644
--- a/src/main/java/org/apache/joshua/decoder/Translation.java
+++ b/src/main/java/org/apache/joshua/decoder/Translation.java
@@ -152,8 +152,7 @@ public class Translation {
out.flush();
} catch (IOException e) {
- e.printStackTrace();
- System.exit(1);
+ throw new RuntimeException(e);
}
this.output = sw.toString();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java b/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
index 5661ce7..db70509 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
@@ -20,7 +20,7 @@ package org.apache.joshua.decoder.ff;
import java.io.IOException;
import java.util.HashSet;
-import java.util.LinkedList;
+import java.util.LinkedList;
import java.util.List;
import org.apache.joshua.corpus.Vocabulary;
@@ -36,32 +36,32 @@ import org.apache.joshua.util.io.LineReader;
/***
* The RuleBigram feature is an indicator feature that counts target word bigrams that are created when
* a rule is applied. It accepts three parameters:
- *
+ *
* -vocab /path/to/vocab
- *
+ *
* The path to a vocabulary, where each line is of the format ID WORD COUNT.
- *
+ *
* -threshold N
- *
+ *
* Mask to UNK all words whose COUNT is less than N.
- *
+ *
* -top-n N
- *
+ *
* Only use the top N words.
*/
public class TargetBigram extends StatefulFF {
-
+
private HashSet<String> vocab = null;
private int maxTerms = 1000000;
private int threshold = 0;
public TargetBigram(FeatureVector weights, String[] args, JoshuaConfiguration config) {
super(weights, "TargetBigram", args, config);
-
+
if (parsedArgs.containsKey("threshold"))
threshold = Integer.parseInt(parsedArgs.get("threshold"));
-
+
if (parsedArgs.containsKey("top-n"))
maxTerms = Integer.parseInt(parsedArgs.get("top-n"));
@@ -72,11 +72,11 @@ public class TargetBigram extends StatefulFF {
/**
* Load vocabulary items passing the 'threshold' and 'top-n' filters.
- *
+ *
* @param filename
*/
private void loadVocab(String filename) {
- this.vocab = new HashSet<String>();
+ this.vocab = new HashSet<String>();
this.vocab.add("<s>");
this.vocab.add("</s>");
try {
@@ -84,18 +84,18 @@ public class TargetBigram extends StatefulFF {
for (String line: lineReader) {
if (lineReader.lineno() > maxTerms)
break;
-
+
String[] tokens = line.split("\\s+");
String word = tokens[1];
int count = Integer.parseInt(tokens[2]);
-
+
if (count >= threshold)
vocab.add(word);
}
} catch (IOException e) {
- System.err.println(String.format("* FATAL: couldn't load TargetBigram vocabulary '%s'", filename));
- System.exit(1);
+ throw new RuntimeException(String.format(
+ "* FATAL: couldn't load TargetBigram vocabulary '%s'", filename), e);
}
}
@@ -107,7 +107,7 @@ public class TargetBigram extends StatefulFF {
int left = -1;
int right = -1;
-
+
List<String> currentNgram = new LinkedList<String>();
for (int c = 0; c < enWords.length; c++) {
int curID = enWords[c];
@@ -127,7 +127,7 @@ public class TargetBigram extends StatefulFF {
if (currentNgram.size() == 2) {
String ngram = join(currentNgram);
acc.add(String.format("%s_%s", name, ngram), 1);
-// System.err.println(String.format("ADDING %s_%s", name, ngram));
+ // System.err.println(String.format("ADDING %s_%s", name, ngram));
currentNgram.remove(0);
}
}
@@ -144,20 +144,20 @@ public class TargetBigram extends StatefulFF {
if (currentNgram.size() == 2) {
String ngram = join(currentNgram);
acc.add(String.format("%s_%s", name, ngram), 1);
-// System.err.println(String.format("ADDING %s_%s", name, ngram));
+ // System.err.println(String.format("ADDING %s_%s", name, ngram));
currentNgram.remove(0);
}
}
}
NgramDPState state = new NgramDPState(new int[] { left }, new int[] { right });
-// System.err.println(String.format("RULE %s -> state %s", rule.getRuleString(), state));
+ // System.err.println(String.format("RULE %s -> state %s", rule.getRuleString(), state));
return state;
}
/**
* Returns the word after comparing against the private vocabulary (if set).
- *
+ *
* @param curID
* @return the word
*/
@@ -165,9 +165,9 @@ public class TargetBigram extends StatefulFF {
String word = Vocabulary.word(curID);
if (vocab != null && ! vocab.contains(word)) {
- return "UNK";
+ return "UNK";
}
-
+
return word;
}
@@ -186,7 +186,7 @@ public class TargetBigram extends StatefulFF {
@Override
public DPState computeFinal(HGNode tailNode, int i, int j, SourcePath sourcePath,
Sentence sentence, Accumulator acc) {
-
+
return tailNode.getDPState(stateIndex);
}
@@ -200,7 +200,7 @@ public class TargetBigram extends StatefulFF {
/**
* Join a list with the _ character. I am sure this is in a library somewhere.
- *
+ *
* @param list a list of strings
* @return the joined String
*/
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
index e438778..c935eba 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
@@ -128,9 +128,8 @@ public class FragmentLMFF extends StatefulFF {
// lmFragments.get(lmFragments.size()-1)));
}
} catch (IOException e) {
- System.err.println(String.format("* WARNING: couldn't read fragment LM file '%s'",
- fragmentLMFile));
- System.exit(1);
+ throw new RuntimeException(String.format("* WARNING: couldn't read fragment LM file '%s'",
+ fragmentLMFile), e);
}
System.err.println(String.format("FragmentLMFF: Read %d LM fragments from '%s'", numFragments,
fragmentLMFile));
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Tree.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Tree.java b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Tree.java
index 6214560..02741e4 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Tree.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Tree.java
@@ -517,9 +517,8 @@ public class Tree implements Serializable {
rulesToFragmentStrings.put(fields[1].trim(), fields[0].trim()); // buildFragment(fields[0]));
}
} catch (IOException e) {
- System.err.println(String.format("* WARNING: couldn't read fragment mapping file '%s'",
- fragmentMappingFile));
- System.exit(1);
+ throw new RuntimeException(String.format("* WARNING: couldn't read fragment mapping file '%s'",
+ fragmentMappingFile), e);
}
System.err.println(String.format("FragmentLMFF: Read %d mappings from '%s'",
rulesToFragmentStrings.size(), fragmentMappingFile));
@@ -729,13 +728,13 @@ public class Tree implements Serializable {
frontierTree.children = tree.children;
}
} catch (IndexOutOfBoundsException e) {
+ //TODO: send these prints to LOG.err
System.err.println(String.format("ERROR at index %d", i));
System.err.println(String.format("RULE: %s TREE: %s", rule.getEnglishWords(), tree));
System.err.println(" FRONTIER:");
for (Tree kid : frontier)
System.err.println(" " + kid);
- e.printStackTrace();
- System.exit(1);
+ throw new RuntimeException(String.format("ERROR at index %d", i), e);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/ff/lm/KenLM.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/KenLM.java b/src/main/java/org/apache/joshua/decoder/ff/lm/KenLM.java
index 2c43712..e012421 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/KenLM.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/KenLM.java
@@ -38,13 +38,14 @@ public class KenLM implements NGramLanguageModel, Comparable<KenLM> {
try {
System.loadLibrary("ken");
} catch (UnsatisfiedLinkError e) {
+ //TODO: send these prints to LOG.err
System.err.println("* FATAL: Can't find libken.so (libken.dylib on OS X) in $JOSHUA/lib");
System.err.println("* This probably means that the KenLM library didn't compile.");
System.err.println("* Make sure that BOOST_ROOT is set to the root of your boost");
System.err.println("* installation (it's not /opt/local/, the default), change to");
System.err.println("* $JOSHUA, and type 'ant kenlm'. If problems persist, see the");
System.err.println("* website (joshua-decoder.org).");
- System.exit(1);
+ throw new RuntimeException(e);
}
}
@@ -161,8 +162,7 @@ public class KenLM implements NGramLanguageModel, Comparable<KenLM> {
try {
estimate = estimateRule(pointer, words);
} catch (NoSuchMethodError e) {
- e.printStackTrace();
- System.exit(1);
+ throw new RuntimeException(e);
}
return estimate;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/ff/lm/LanguageModelFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/LanguageModelFF.java b/src/main/java/org/apache/joshua/decoder/ff/lm/LanguageModelFF.java
index f2daffd..741fea6 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/LanguageModelFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/LanguageModelFF.java
@@ -173,9 +173,9 @@ public class LanguageModelFF extends StatefulFF {
this.languageModel = new LMGrammarBerkeley(ngramOrder, path);
} else {
- System.err.println(String.format("* FATAL: Invalid backend lm_type '%s' for LanguageModel", type));
- System.err.println(String.format("* Permissible values for 'lm_type' are 'kenlm' and 'berkeleylm'"));
- System.exit(-1);
+ String msg = String.format("* FATAL: Invalid backend lm_type '%s' for LanguageModel", type)
+ + "* Permissible values for 'lm_type' are 'kenlm' and 'berkeleylm'";
+ throw new RuntimeException(msg);
}
Vocabulary.registerLanguageModel(this.languageModel);
@@ -278,8 +278,7 @@ public class LanguageModelFF extends StatefulFF {
*/
protected int[] getClasses(Rule rule) {
if (this.classMap == null) {
- System.err.println("The class map is not set. Cannot use the class LM ");
- System.exit(2);
+ throw new RuntimeException("The class map is not set. Cannot use the class LM ");
}
/* Very important to make a copy here, so the original rule is not modified */
int[] tokens = Arrays.copyOf(rule.getEnglish(), rule.getEnglish().length);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java b/src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java
index b3f6eca..9bf4cc7 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java
@@ -49,9 +49,9 @@ public class StateMinimizingLanguageModel extends LanguageModelFF {
super(weights, args, config);
this.type = "kenlm";
if (parsedArgs.containsKey("lm_type") && ! parsedArgs.get("lm_type").equals("kenlm")) {
- System.err.println("* FATAL: StateMinimizingLanguageModel only supports 'kenlm' lm_type backend");
- System.err.println("* Remove lm_type from line or set to 'kenlm'");
- System.exit(-1);
+ String msg = "* FATAL: StateMinimizingLanguageModel only supports 'kenlm' lm_type backend"
+ + "* Remove lm_type from line or set to 'kenlm'";
+ throw new RuntimeException(msg);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/ff/lm/berkeley_lm/LMGrammarBerkeley.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/berkeley_lm/LMGrammarBerkeley.java b/src/main/java/org/apache/joshua/decoder/ff/lm/berkeley_lm/LMGrammarBerkeley.java
index 6d80d93..859ca6a 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/berkeley_lm/LMGrammarBerkeley.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/berkeley_lm/LMGrammarBerkeley.java
@@ -72,8 +72,7 @@ public class LMGrammarBerkeley extends DefaultNGramLanguageModel {
vocabIdToMyIdMapping = new int[10];
if (!new File(lm_file).exists()) {
- System.err.println("Can't read lm_file '" + lm_file + "'");
- System.exit(1);
+ throw new RuntimeException("Can't read lm_file '" + lm_file + "'");
}
if (logRequests) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/ff/phrase/Distortion.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/phrase/Distortion.java b/src/main/java/org/apache/joshua/decoder/ff/phrase/Distortion.java
index c9a3214..abe115c 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/phrase/Distortion.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/phrase/Distortion.java
@@ -37,9 +37,9 @@ public class Distortion extends StatelessFF {
super(weights, "Distortion", args, config);
if (! config.search_algorithm.equals("stack")) {
- System.err.println("* FATAL: Distortion feature only application for phrase-based decoding");
- System.err.println(" Use -search phrase or remove this feature");
- System.exit(1);
+ String msg = "* FATAL: Distortion feature only application for phrase-based decoding. "
+ + "Use -search phrase or remove this feature";
+ throw new RuntimeException(msg);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/hypergraph/HGNode.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/HGNode.java b/src/main/java/org/apache/joshua/decoder/hypergraph/HGNode.java
index a38fec9..d9cd4a8 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/HGNode.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/HGNode.java
@@ -241,9 +241,7 @@ public class HGNode {
*/
// sort by estTotalLogP: for pruning purpose
public int compareTo(HGNode anotherItem) {
- System.out.println("HGNode, compare functiuon should never be called");
- System.exit(1);
- return 0;
+ throw new RuntimeException("HGNode, compare functiuon should never be called");
/*
* if (this.estTotalLogP > anotherItem.estTotalLogP) { return -1; } else if (this.estTotalLogP
* == anotherItem.estTotalLogP) { return 0; } else { return 1; }
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/phrase/PhraseTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/PhraseTable.java b/src/main/java/org/apache/joshua/decoder/phrase/PhraseTable.java
index db76924..c937b50 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/PhraseTable.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/PhraseTable.java
@@ -60,9 +60,9 @@ public class PhraseTable implements Grammar {
if (grammarFile != null && new File(grammarFile).isDirectory()) {
this.backend = new PackedGrammar(grammarFile, spanLimit, owner, type, config);
if (this.backend.getMaxSourcePhraseLength() == -1) {
- System.err.println("FATAL: Using a packed grammar for a phrase table backend requires that you");
- System.err.println(" packed the grammar with Joshua 6.0.2 or greater");
- System.exit(-1);
+ String msg = "FATAL: Using a packed grammar for a phrase table backend requires that you "
+ + "packed the grammar with Joshua 6.0.2 or greater";
+ throw new RuntimeException(msg);
}
} else {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/decoder/segment_file/Sentence.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/segment_file/Sentence.java b/src/main/java/org/apache/joshua/decoder/segment_file/Sentence.java
index 2f45ced..d3a5e79 100644
--- a/src/main/java/org/apache/joshua/decoder/segment_file/Sentence.java
+++ b/src/main/java/org/apache/joshua/decoder/segment_file/Sentence.java
@@ -410,8 +410,7 @@ public class Sentence {
if (this.sourceLattice == null) {
if (config.lattice_decoding && rawSource().startsWith("(((")) {
if (config.search_algorithm.equals("stack")) {
- System.err.println("* FATAL: lattice decoding currently not supported for stack-based search algorithm.");
- System.exit(12);
+ throw new RuntimeException("* FATAL: lattice decoding currently not supported for stack-based search algorithm.");
}
this.sourceLattice = Lattice.createTokenLatticeFromPLF(rawSource(), config);
} else
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/BLEU.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/BLEU.java b/src/main/java/org/apache/joshua/metrics/BLEU.java
index a37dcaf..1d14d36 100644
--- a/src/main/java/org/apache/joshua/metrics/BLEU.java
+++ b/src/main/java/org/apache/joshua/metrics/BLEU.java
@@ -49,7 +49,7 @@ public class BLEU extends EvaluationMetric {
setMaxGramLength(mxGrmLn);
} else {
logger.severe("Maximum gram length must be positive");
- System.exit(1);
+ throw new RuntimeException("Maximum gram length must be positive");
}
if (methodStr.equals("closest")) {
@@ -62,7 +62,7 @@ public class BLEU extends EvaluationMetric {
logger.severe("Unknown effective length method string " + methodStr + ".");
// System.out.println("Should be one of closest, shortest, or average.");
logger.severe("Should be one of closest or shortest.");
- System.exit(1);
+ throw new RuntimeException("Should be one of closest or shortest.");
}
initialize();
@@ -261,9 +261,10 @@ public class BLEU extends EvaluationMetric {
public double score(int[] stats) {
if (stats.length != suffStatsCount) {
- logger.severe("Mismatch between stats.length and suffStatsCount (" + stats.length + " vs. "
- + suffStatsCount + ") in BLEU.score(int[])");
- System.exit(2);
+ String msg = "Mismatch between stats.length and suffStatsCount (" + stats.length + " vs. "
+ + suffStatsCount + ") in BLEU.score(int[])";
+ logger.severe(msg);
+ throw new RuntimeException(msg);
}
double BLEUsum = 0.0;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/EvaluationMetric.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/EvaluationMetric.java b/src/main/java/org/apache/joshua/metrics/EvaluationMetric.java
index 4ca1675..cce51f8 100644
--- a/src/main/java/org/apache/joshua/metrics/EvaluationMetric.java
+++ b/src/main/java/org/apache/joshua/metrics/EvaluationMetric.java
@@ -303,9 +303,8 @@ public abstract class EvaluationMetric {
outFile.close();
} catch (IOException e) {
- System.err.println("IOException in EvaluationMetric.createSuffStatsFile(...): "
- + e.getMessage());
- System.exit(99902);
+ throw new RuntimeException("IOException in EvaluationMetric.createSuffStatsFile(...): "
+ + e.getMessage(), e);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/9848541f/src/main/java/org/apache/joshua/metrics/GradeLevelBLEU.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/GradeLevelBLEU.java b/src/main/java/org/apache/joshua/metrics/GradeLevelBLEU.java
index da9f549..8c0366c 100644
--- a/src/main/java/org/apache/joshua/metrics/GradeLevelBLEU.java
+++ b/src/main/java/org/apache/joshua/metrics/GradeLevelBLEU.java
@@ -59,8 +59,7 @@ public class GradeLevelBLEU extends BLEU {
try {
loadSources(options[2]);
} catch (IOException e) {
- logger.severe("Error loading the source sentences from " + options[2]);
- System.exit(1);
+ throw new RuntimeException("Error loading the source sentences from " + options[2], e);
}
if (useBLEUplus) srcBLEU = new SourceBLEU(4, "closest", srcIndex, true);
initialize();
@@ -183,9 +182,10 @@ public class GradeLevelBLEU extends BLEU {
public double score(int[] stats) {
if (stats.length != suffStatsCount) {
- logger.severe("Mismatch between stats.length and suffStatsCount (" + stats.length + " vs. "
- + suffStatsCount + ") in BLEU.score(int[])");
- System.exit(2);
+ String msg = "Mismatch between stats.length and suffStatsCount (" + stats.length + " vs. "
+ + suffStatsCount + ") in BLEU.score(int[])";
+ logger.severe(msg);
+ throw new RuntimeException(msg);
}
double BLEUscore = super.score(stats);
double candGL =
[4/6] incubator-joshua git commit: Merge branch 'JOSHUA-264' of
https://github.com/thammegowda/incubator-joshua into JOSHUA-264
Posted by mj...@apache.org.
Merge branch 'JOSHUA-264' of https://github.com/thammegowda/incubator-joshua into JOSHUA-264
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/f354c298
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/f354c298
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/f354c298
Branch: refs/heads/JOSHUA-264
Commit: f354c298ff9d1f16b8c034a5d885428d95e43ca3
Parents: 09fb6a2 9848541
Author: Matt Post <po...@cs.jhu.edu>
Authored: Mon May 16 18:20:45 2016 -0400
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Mon May 16 18:20:45 2016 -0400
----------------------------------------------------------------------
.gitmodules | 3 -
.project | 18 -
.settings/org.eclipse.core.resources.prefs | 3 -
.settings/org.eclipse.jdt.core.prefs | 285 -
.settings/org.eclipse.jdt.ui.prefs | 4 -
lib/.gitignore | 13 -
lib/BerkeleyParser.jar | Bin 3092739 -> 0 bytes
lib/LICENSES/LICENSE-jung.txt | 45 -
lib/LICENSES/LICENSE-pmd.txt | 36 -
lib/README | 26 -
lib/berkeleyaligner.jar | Bin 1202003 -> 0 bytes
lib/eng_sm6.gr | Bin 22243222 -> 0 bytes
lib/fastutil.jar | Bin 13943025 -> 0 bytes
lib/ghkm-modified.jar | Bin 3883068 -> 0 bytes
lib/ivy.xml | 17 -
lib/ivysettings.xml | 18 -
lib/jacana-xy.jar | Bin 19949544 -> 0 bytes
pom.xml | 177 +-
src/joshua/adagrad/AdaGrad.java | 160 -
src/joshua/adagrad/AdaGradCore.java | 3213 ---
src/joshua/adagrad/Optimizer.java | 728 -
src/joshua/corpus/AbstractPhrase.java | 135 -
src/joshua/corpus/BasicPhrase.java | 86 -
src/joshua/corpus/ContiguousPhrase.java | 187 -
src/joshua/corpus/Corpus.java | 159 -
src/joshua/corpus/Phrase.java | 114 -
src/joshua/corpus/Span.java | 175 -
src/joshua/corpus/TerminalIterator.java | 84 -
src/joshua/corpus/Vocabulary.java | 278 -
src/joshua/corpus/package.html | 19 -
src/joshua/corpus/syntax/ArraySyntaxTree.java | 422 -
src/joshua/corpus/syntax/SyntaxTree.java | 34 -
src/joshua/decoder/ArgsParser.java | 116 -
src/joshua/decoder/BLEU.java | 557 -
src/joshua/decoder/Decoder.java | 993 -
src/joshua/decoder/DecoderThread.java | 199 -
src/joshua/decoder/JoshuaConfiguration.java | 710 -
src/joshua/decoder/JoshuaDecoder.java | 124 -
src/joshua/decoder/MetaDataException.java | 56 -
src/joshua/decoder/NbestMinRiskReranker.java | 441 -
src/joshua/decoder/StructuredTranslation.java | 125 -
src/joshua/decoder/Support.java | 85 -
src/joshua/decoder/Translation.java | 202 -
src/joshua/decoder/Translations.java | 130 -
src/joshua/decoder/chart_parser/Cell.java | 291 -
src/joshua/decoder/chart_parser/Chart.java | 748 -
.../decoder/chart_parser/ComputeNodeResult.java | 205 -
.../decoder/chart_parser/CubePruneState.java | 116 -
src/joshua/decoder/chart_parser/DotChart.java | 494 -
.../chart_parser/ManualConstraintsHandler.java | 217 -
src/joshua/decoder/chart_parser/SourcePath.java | 63 -
.../decoder/chart_parser/StateConstraint.java | 75 -
src/joshua/decoder/chart_parser/SuperNode.java | 62 -
src/joshua/decoder/chart_parser/package.html | 23 -
src/joshua/decoder/ff/ArityPhrasePenalty.java | 72 -
src/joshua/decoder/ff/FeatureFunction.java | 361 -
src/joshua/decoder/ff/FeatureVector.java | 368 -
src/joshua/decoder/ff/LabelCombinationFF.java | 63 -
src/joshua/decoder/ff/LabelSubstitutionFF.java | 132 -
src/joshua/decoder/ff/OOVPenalty.java | 105 -
src/joshua/decoder/ff/PhraseModel.java | 135 -
src/joshua/decoder/ff/PhrasePenalty.java | 86 -
src/joshua/decoder/ff/RuleCountBin.java | 70 -
src/joshua/decoder/ff/RuleFF.java | 88 -
src/joshua/decoder/ff/RuleLength.java | 51 -
.../decoder/ff/RulePropertiesQuerying.java | 49 -
src/joshua/decoder/ff/RuleShape.java | 73 -
src/joshua/decoder/ff/SourceDependentFF.java | 29 -
src/joshua/decoder/ff/SourcePathFF.java | 63 -
src/joshua/decoder/ff/StatefulFF.java | 86 -
src/joshua/decoder/ff/StatelessFF.java | 79 -
src/joshua/decoder/ff/TargetBigram.java | 215 -
src/joshua/decoder/ff/WordPenalty.java | 78 -
.../ff/fragmentlm/ConcatenationIterator.java | 87 -
.../decoder/ff/fragmentlm/FragmentLMFF.java | 356 -
.../ff/fragmentlm/PennTreebankReader.java | 135 -
src/joshua/decoder/ff/fragmentlm/Tree.java | 776 -
src/joshua/decoder/ff/fragmentlm/Trees.java | 265 -
.../ff/lm/DefaultNGramLanguageModel.java | 140 -
src/joshua/decoder/ff/lm/KenLM.java | 224 -
src/joshua/decoder/ff/lm/LanguageModelFF.java | 520 -
.../decoder/ff/lm/NGramLanguageModel.java | 73 -
.../ff/lm/StateMinimizingLanguageModel.java | 205 -
src/joshua/decoder/ff/lm/berkeley_lm/LICENSE | 13 -
.../ff/lm/berkeley_lm/LMGrammarBerkeley.java | 203 -
src/joshua/decoder/ff/lm/berkeley_lm/README | 5 -
.../ff/lm/berkeley_lm/SymbolTableWrapper.java | 102 -
.../ff/lm/bloomfilter_lm/BloomFilter.java | 215 -
.../BloomFilterLanguageModel.java | 562 -
.../decoder/ff/lm/bloomfilter_lm/package.html | 19 -
src/joshua/decoder/ff/lm/package.html | 35 -
src/joshua/decoder/ff/package.html | 37 -
src/joshua/decoder/ff/phrase/Distortion.java | 71 -
.../ff/similarity/EdgePhraseSimilarityFF.java | 277 -
.../decoder/ff/state_maintenance/DPState.java | 34 -
.../ff/state_maintenance/KenLMState.java | 56 -
.../ff/state_maintenance/NgramDPState.java | 100 -
src/joshua/decoder/ff/tm/AbstractGrammar.java | 225 -
.../decoder/ff/tm/BasicRuleCollection.java | 101 -
src/joshua/decoder/ff/tm/CreateGlueGrammar.java | 127 -
src/joshua/decoder/ff/tm/Grammar.java | 140 -
src/joshua/decoder/ff/tm/GrammarReader.java | 207 -
src/joshua/decoder/ff/tm/PhraseRule.java | 94 -
src/joshua/decoder/ff/tm/Rule.java | 606 -
src/joshua/decoder/ff/tm/RuleCollection.java | 72 -
.../decoder/ff/tm/SentenceFilteredGrammar.java | 373 -
src/joshua/decoder/ff/tm/Trie.java | 106 -
.../ff/tm/UnsortedRuleCollectionException.java | 40 -
.../decoder/ff/tm/format/HieroFormatReader.java | 123 -
.../ff/tm/format/PhraseFormatReader.java | 128 -
.../decoder/ff/tm/format/SamtFormatReader.java | 136 -
.../ff/tm/hash_based/ExtensionIterator.java | 73 -
.../tm/hash_based/MemoryBasedBatchGrammar.java | 318 -
.../ff/tm/hash_based/MemoryBasedRuleBin.java | 59 -
.../ff/tm/hash_based/MemoryBasedTrie.java | 88 -
.../decoder/ff/tm/hash_based/package.html | 17 -
src/joshua/decoder/ff/tm/package.html | 17 -
.../decoder/ff/tm/packed/PackedGrammar.java | 1053 -
.../ff/tm/packed/SliceAggregatingTrie.java | 235 -
.../decoder/hypergraph/AlignedSourceTokens.java | 111 -
.../decoder/hypergraph/AllSpansWalker.java | 62 -
.../hypergraph/DefaultInsideOutside.java | 407 -
.../hypergraph/FeatureVectorExtractor.java | 80 -
src/joshua/decoder/hypergraph/ForestWalker.java | 79 -
.../GrammarBuilderWalkerFunction.java | 175 -
src/joshua/decoder/hypergraph/HGNode.java | 328 -
src/joshua/decoder/hypergraph/HyperEdge.java | 108 -
src/joshua/decoder/hypergraph/HyperGraph.java | 161 -
.../decoder/hypergraph/HyperGraphPruning.java | 176 -
.../decoder/hypergraph/KBestExtractor.java | 1006 -
.../hypergraph/OutputStringExtractor.java | 195 -
.../hypergraph/StringToTreeConverter.java | 74 -
.../hypergraph/TrivialInsideOutside.java | 31 -
.../decoder/hypergraph/ViterbiExtractor.java | 162 -
.../decoder/hypergraph/WalkerFunction.java | 34 -
.../hypergraph/WordAlignmentExtractor.java | 133 -
.../decoder/hypergraph/WordAlignmentState.java | 171 -
src/joshua/decoder/hypergraph/package.html | 18 -
src/joshua/decoder/io/DeNormalize.java | 205 -
src/joshua/decoder/io/JSONMessage.java | 109 -
.../decoder/io/TranslationRequestStream.java | 186 -
src/joshua/decoder/package.html | 21 -
src/joshua/decoder/phrase/Candidate.java | 241 -
.../decoder/phrase/CandidateComparator.java | 28 -
src/joshua/decoder/phrase/Coverage.java | 231 -
src/joshua/decoder/phrase/CoverageTest.java | 140 -
src/joshua/decoder/phrase/Future.java | 117 -
src/joshua/decoder/phrase/Header.java | 81 -
src/joshua/decoder/phrase/Hypothesis.java | 154 -
src/joshua/decoder/phrase/Note.java | 44 -
src/joshua/decoder/phrase/PhraseChart.java | 191 -
src/joshua/decoder/phrase/PhraseTable.java | 201 -
src/joshua/decoder/phrase/Stack.java | 234 -
src/joshua/decoder/phrase/Stacks.java | 266 -
src/joshua/decoder/phrase/TargetPhrases.java | 77 -
.../decoder/segment_file/ConstraintRule.java | 94 -
.../decoder/segment_file/ConstraintSpan.java | 76 -
.../decoder/segment_file/ParseTreeInput.java | 40 -
.../decoder/segment_file/ParsedSentence.java | 56 -
src/joshua/decoder/segment_file/Sentence.java | 440 -
src/joshua/decoder/segment_file/Token.java | 147 -
src/joshua/decoder/segment_file/package.html | 17 -
src/joshua/lattice/Arc.java | 118 -
src/joshua/lattice/Lattice.java | 515 -
src/joshua/lattice/Node.java | 158 -
.../lattice/NodeIdentifierComparator.java | 41 -
src/joshua/lattice/package.html | 18 -
src/joshua/metrics/BLEU.java | 540 -
src/joshua/metrics/BLEU_SBP.java | 63 -
src/joshua/metrics/EvaluationMetric.java | 399 -
src/joshua/metrics/GradeLevelBLEU.java | 278 -
src/joshua/metrics/METEOR.java | 243 -
src/joshua/metrics/MinimumChangeBLEU.java | 221 -
src/joshua/metrics/NewMetric.java.template | 134 -
src/joshua/metrics/Precis.java | 332 -
src/joshua/metrics/PrecisMinusSourceBLEU.java | 184 -
src/joshua/metrics/SourceBLEU.java | 107 -
src/joshua/metrics/TER.java | 477 -
src/joshua/metrics/TERMinusBLEU.java | 196 -
src/joshua/metrics/TercomRunner.java | 120 -
src/joshua/metrics/ZeroOneLoss.java | 89 -
src/joshua/mira/MIRA.java | 160 -
src/joshua/mira/MIRACore.java | 3200 ---
src/joshua/mira/Optimizer.java | 643 -
src/joshua/oracle/OracleExtractionHG.java | 793 -
src/joshua/oracle/OracleExtractor.java | 58 -
src/joshua/oracle/SplitHg.java | 300 -
src/joshua/oracle/package.html | 24 -
src/joshua/pro/ClassifierInterface.java | 41 -
src/joshua/pro/ClassifierMegaM.java | 126 -
src/joshua/pro/ClassifierPerceptron.java | 109 -
src/joshua/pro/ClassifierSVM.java | 144 -
src/joshua/pro/Optimizer.java | 463 -
src/joshua/pro/PRO.java | 159 -
src/joshua/pro/PROCore.java | 3106 ---
src/joshua/server/ServerThread.java | 138 -
src/joshua/server/TcpServer.java | 65 -
src/joshua/subsample/AlignedSubsampler.java | 102 -
src/joshua/subsample/Alignment.java | 84 -
src/joshua/subsample/BiCorpus.java | 172 -
src/joshua/subsample/BiCorpusFactory.java | 69 -
src/joshua/subsample/PhrasePair.java | 64 -
src/joshua/subsample/PhraseReader.java | 36 -
src/joshua/subsample/PhraseWriter.java | 79 -
src/joshua/subsample/Subsampler.java | 228 -
src/joshua/subsample/SubsamplerCLI.java | 121 -
src/joshua/subsample/package.html | 25 -
src/joshua/tools/GrammarPacker.java | 983 -
src/joshua/tools/GrammarPackerCli.java | 155 -
src/joshua/tools/LabelPhrases.java | 112 -
src/joshua/tools/TestSetFilter.java | 376 -
src/joshua/ui/Orientation.java | 23 -
src/joshua/ui/StartupWindow.java | 87 -
src/joshua/ui/package.html | 25 -
.../ui/tree_visualizer/DerivationTree.java | 103 -
.../ui/tree_visualizer/DerivationTreeEdge.java | 27 -
.../DerivationTreeTransformer.java | 117 -
.../ui/tree_visualizer/DerivationViewer.java | 128 -
.../tree_visualizer/DerivationViewerApplet.java | 51 -
src/joshua/ui/tree_visualizer/Node.java | 59 -
.../ui/tree_visualizer/browser/Browser.java | 236 -
.../browser/DerivationTreeFrame.java | 253 -
.../browser/TranslationInfo.java | 56 -
src/joshua/ui/tree_visualizer/tree/Tree.java | 279 -
src/joshua/util/Algorithms.java | 83 -
src/joshua/util/Bits.java | 128 -
src/joshua/util/BotMap.java | 94 -
src/joshua/util/Cache.java | 186 -
src/joshua/util/ChartSpan.java | 91 -
src/joshua/util/CommandLineParser.java | 738 -
src/joshua/util/CompareGrammars.java | 207 -
src/joshua/util/Counted.java | 93 -
src/joshua/util/Counts.java | 308 -
src/joshua/util/ExtractTopCand.java | 179 -
src/joshua/util/FileUtility.java | 314 -
src/joshua/util/FormatUtils.java | 224 -
src/joshua/util/IntegerPair.java | 36 -
src/joshua/util/JoshuaEval.java | 648 -
src/joshua/util/ListUtil.java | 95 -
src/joshua/util/Lists.java | 567 -
src/joshua/util/NBestListUtility.java | 74 -
src/joshua/util/Ngram.java | 93 -
src/joshua/util/NullIterator.java | 65 -
src/joshua/util/PackedGrammarServer.java | 87 -
src/joshua/util/Pair.java | 130 -
src/joshua/util/Platform.java | 28 -
src/joshua/util/QuietFormatter.java | 36 -
src/joshua/util/Regex.java | 130 -
src/joshua/util/ReverseOrder.java | 39 -
src/joshua/util/SampledList.java | 69 -
src/joshua/util/SocketUtility.java | 154 -
src/joshua/util/StreamGobbler.java | 50 -
src/joshua/util/UnicodeCharacterName.java | 22466 -----------------
src/joshua/util/encoding/Analyzer.java | 235 -
src/joshua/util/encoding/EightBitQuantizer.java | 92 -
.../util/encoding/EncoderConfiguration.java | 162 -
src/joshua/util/encoding/EncoderFactory.java | 42 -
.../util/encoding/FeatureTypeAnalyzer.java | 250 -
src/joshua/util/encoding/FloatEncoder.java | 39 -
src/joshua/util/encoding/IntEncoder.java | 39 -
.../util/encoding/PrimitiveFloatEncoder.java | 129 -
.../util/encoding/PrimitiveIntEncoder.java | 111 -
src/joshua/util/encoding/VariableQuantizer.java | 106 -
src/joshua/util/io/BinaryIn.java | 104 -
src/joshua/util/io/BinaryOut.java | 508 -
src/joshua/util/io/IndexedReader.java | 150 -
src/joshua/util/io/LineReader.java | 366 -
src/joshua/util/io/NullReader.java | 63 -
src/joshua/util/io/ProgressInputStream.java | 82 -
src/joshua/util/io/Reader.java | 40 -
src/joshua/util/io/package.html | 18 -
src/joshua/util/package.html | 18 -
src/joshua/zmert/IntermediateOptimizer.java | 1002 -
src/joshua/zmert/MertCore.java | 3268 ---
src/joshua/zmert/ZMERT.java | 156 -
src/joshua/zmert/package.html | 24 -
.../java/org/apache/joshua/adagrad/AdaGrad.java | 160 +
.../org/apache/joshua/adagrad/AdaGradCore.java | 3127 +++
.../org/apache/joshua/adagrad/Optimizer.java | 728 +
.../apache/joshua/corpus/AbstractPhrase.java | 133 +
.../org/apache/joshua/corpus/BasicPhrase.java | 86 +
.../apache/joshua/corpus/ContiguousPhrase.java | 185 +
.../java/org/apache/joshua/corpus/Corpus.java | 157 +
.../java/org/apache/joshua/corpus/Phrase.java | 114 +
.../java/org/apache/joshua/corpus/Span.java | 175 +
.../org/apache/joshua/corpus/SymbolTable.java | 330 +
.../apache/joshua/corpus/TerminalIterator.java | 84 +
.../org/apache/joshua/corpus/Vocabulary.java | 278 +
.../java/org/apache/joshua/corpus/package.html | 19 +
.../joshua/corpus/syntax/ArraySyntaxTree.java | 422 +
.../apache/joshua/corpus/syntax/SyntaxTree.java | 34 +
.../org/apache/joshua/decoder/ArgsParser.java | 115 +
.../java/org/apache/joshua/decoder/BLEU.java | 555 +
.../java/org/apache/joshua/decoder/Decoder.java | 983 +
.../apache/joshua/decoder/DecoderThread.java | 199 +
.../joshua/decoder/JoshuaConfiguration.java | 705 +
.../apache/joshua/decoder/JoshuaDecoder.java | 124 +
.../joshua/decoder/MetaDataException.java | 56 +
.../joshua/decoder/NbestMinRiskReranker.java | 441 +
.../joshua/decoder/StructuredTranslation.java | 125 +
.../java/org/apache/joshua/decoder/Support.java | 85 +
.../org/apache/joshua/decoder/Translation.java | 201 +
.../org/apache/joshua/decoder/Translations.java | 130 +
.../joshua/decoder/chart_parser/Cell.java | 291 +
.../joshua/decoder/chart_parser/Chart.java | 748 +
.../decoder/chart_parser/ComputeNodeResult.java | 205 +
.../decoder/chart_parser/CubePruneState.java | 116 +
.../joshua/decoder/chart_parser/DotChart.java | 494 +
.../chart_parser/ManualConstraintsHandler.java | 217 +
.../joshua/decoder/chart_parser/SourcePath.java | 63 +
.../decoder/chart_parser/StateConstraint.java | 75 +
.../joshua/decoder/chart_parser/SuperNode.java | 62 +
.../joshua/decoder/chart_parser/package.html | 23 +
.../joshua/decoder/ff/ArityPhrasePenalty.java | 84 +
.../joshua/decoder/ff/FeatureFunction.java | 370 +
.../apache/joshua/decoder/ff/FeatureVector.java | 368 +
.../joshua/decoder/ff/LabelCombinationFF.java | 75 +
.../joshua/decoder/ff/LabelSubstitutionFF.java | 144 +
.../apache/joshua/decoder/ff/OOVPenalty.java | 117 +
.../apache/joshua/decoder/ff/PhraseModel.java | 147 +
.../apache/joshua/decoder/ff/PhrasePenalty.java | 98 +
.../apache/joshua/decoder/ff/RuleCountBin.java | 82 +
.../org/apache/joshua/decoder/ff/RuleFF.java | 100 +
.../apache/joshua/decoder/ff/RuleLength.java | 51 +
.../decoder/ff/RulePropertiesQuerying.java | 49 +
.../org/apache/joshua/decoder/ff/RuleShape.java | 85 +
.../joshua/decoder/ff/SourceDependentFF.java | 29 +
.../apache/joshua/decoder/ff/SourcePathFF.java | 75 +
.../apache/joshua/decoder/ff/StatefulFF.java | 86 +
.../apache/joshua/decoder/ff/StatelessFF.java | 79 +
.../apache/joshua/decoder/ff/TargetBigram.java | 227 +
.../apache/joshua/decoder/ff/WordPenalty.java | 90 +
.../ff/fragmentlm/ConcatenationIterator.java | 93 +
.../decoder/ff/fragmentlm/FragmentLMFF.java | 367 +
.../ff/fragmentlm/PennTreebankReader.java | 135 +
.../joshua/decoder/ff/fragmentlm/Tree.java | 774 +
.../joshua/decoder/ff/fragmentlm/Trees.java | 267 +
.../apache/joshua/decoder/ff/lm/AbstractLM.java | 133 +
.../apache/joshua/decoder/ff/lm/ArpaFile.java | 335 +
.../apache/joshua/decoder/ff/lm/ArpaNgram.java | 73 +
.../ff/lm/DefaultNGramLanguageModel.java | 140 +
.../org/apache/joshua/decoder/ff/lm/KenLM.java | 224 +
.../joshua/decoder/ff/lm/LanguageModelFF.java | 531 +
.../decoder/ff/lm/NGramLanguageModel.java | 73 +
.../ff/lm/StateMinimizingLanguageModel.java | 205 +
.../joshua/decoder/ff/lm/berkeley_lm/LICENSE | 13 +
.../ff/lm/berkeley_lm/LMGrammarBerkeley.java | 203 +
.../joshua/decoder/ff/lm/berkeley_lm/README | 5 +
.../ff/lm/berkeley_lm/SymbolTableWrapper.java | 102 +
.../ff/lm/bloomfilter_lm/BloomFilter.java | 215 +
.../BloomFilterLanguageModel.java | 562 +
.../decoder/ff/lm/bloomfilter_lm/package.html | 19 +
.../joshua/decoder/ff/lm/buildin_lm/TrieLM.java | 332 +
.../decoder/ff/lm/buildin_lm/package-info.java | 19 +
.../apache/joshua/decoder/ff/lm/package.html | 35 +
.../org/apache/joshua/decoder/ff/package.html | 37 +
.../joshua/decoder/ff/phrase/Distortion.java | 83 +
.../ff/similarity/EdgePhraseSimilarityFF.java | 289 +
.../decoder/ff/state_maintenance/DPState.java | 34 +
.../ff/state_maintenance/KenLMState.java | 56 +
.../ff/state_maintenance/NgramDPState.java | 100 +
.../joshua/decoder/ff/tm/AbstractGrammar.java | 226 +
.../decoder/ff/tm/BasicRuleCollection.java | 101 +
.../joshua/decoder/ff/tm/BilingualRule.java | 167 +
.../joshua/decoder/ff/tm/CreateGlueGrammar.java | 127 +
.../apache/joshua/decoder/ff/tm/Grammar.java | 140 +
.../joshua/decoder/ff/tm/GrammarReader.java | 207 +
.../joshua/decoder/ff/tm/MonolingualRule.java | 315 +
.../apache/joshua/decoder/ff/tm/PhraseRule.java | 94 +
.../org/apache/joshua/decoder/ff/tm/Rule.java | 606 +
.../joshua/decoder/ff/tm/RuleCollection.java | 72 +
.../decoder/ff/tm/SentenceFilteredGrammar.java | 373 +
.../org/apache/joshua/decoder/ff/tm/Trie.java | 106 +
.../ff/tm/UnsortedRuleCollectionException.java | 40 +
.../decoder/ff/tm/format/HieroFormatReader.java | 123 +
.../ff/tm/format/PhraseFormatReader.java | 128 +
.../decoder/ff/tm/format/SamtFormatReader.java | 136 +
.../ff/tm/hash_based/ExtensionIterator.java | 73 +
.../tm/hash_based/MemoryBasedBatchGrammar.java | 318 +
.../ff/tm/hash_based/MemoryBasedRuleBin.java | 59 +
.../ff/tm/hash_based/MemoryBasedTrie.java | 88 +
.../decoder/ff/tm/hash_based/package.html | 17 +
.../apache/joshua/decoder/ff/tm/package.html | 17 +
.../decoder/ff/tm/packed/PackedGrammar.java | 1053 +
.../ff/tm/packed/SliceAggregatingTrie.java | 235 +
.../decoder/hypergraph/AlignedSourceTokens.java | 111 +
.../decoder/hypergraph/AllSpansWalker.java | 62 +
.../hypergraph/DefaultInsideOutside.java | 407 +
.../hypergraph/FeatureVectorExtractor.java | 80 +
.../joshua/decoder/hypergraph/ForestWalker.java | 79 +
.../GrammarBuilderWalkerFunction.java | 175 +
.../joshua/decoder/hypergraph/HGNode.java | 326 +
.../joshua/decoder/hypergraph/HyperEdge.java | 108 +
.../joshua/decoder/hypergraph/HyperGraph.java | 161 +
.../decoder/hypergraph/HyperGraphPruning.java | 176 +
.../decoder/hypergraph/KBestExtractor.java | 1007 +
.../hypergraph/OutputStringExtractor.java | 195 +
.../hypergraph/StringToTreeConverter.java | 74 +
.../hypergraph/TrivialInsideOutside.java | 31 +
.../decoder/hypergraph/ViterbiExtractor.java | 162 +
.../decoder/hypergraph/WalkerFunction.java | 34 +
.../hypergraph/WordAlignmentExtractor.java | 133 +
.../decoder/hypergraph/WordAlignmentState.java | 171 +
.../joshua/decoder/hypergraph/package.html | 18 +
.../apache/joshua/decoder/io/DeNormalize.java | 205 +
.../apache/joshua/decoder/io/JSONMessage.java | 109 +
.../decoder/io/TranslationRequestStream.java | 186 +
.../java/org/apache/joshua/decoder/package.html | 21 +
.../apache/joshua/decoder/phrase/Candidate.java | 241 +
.../decoder/phrase/CandidateComparator.java | 28 +
.../apache/joshua/decoder/phrase/Coverage.java | 231 +
.../apache/joshua/decoder/phrase/Future.java | 109 +
.../apache/joshua/decoder/phrase/Header.java | 81 +
.../joshua/decoder/phrase/Hypothesis.java | 154 +
.../org/apache/joshua/decoder/phrase/Note.java | 44 +
.../joshua/decoder/phrase/PhraseChart.java | 191 +
.../joshua/decoder/phrase/PhraseTable.java | 201 +
.../org/apache/joshua/decoder/phrase/Stack.java | 234 +
.../apache/joshua/decoder/phrase/Stacks.java | 266 +
.../joshua/decoder/phrase/TargetPhrases.java | 77 +
.../decoder/segment_file/ConstraintRule.java | 93 +
.../decoder/segment_file/ConstraintSpan.java | 76 +
.../decoder/segment_file/ParseTreeInput.java | 40 +
.../decoder/segment_file/ParsedSentence.java | 56 +
.../joshua/decoder/segment_file/Sentence.java | 439 +
.../joshua/decoder/segment_file/Token.java | 147 +
.../joshua/decoder/segment_file/package.html | 17 +
.../java/org/apache/joshua/lattice/Arc.java | 117 +
.../java/org/apache/joshua/lattice/Lattice.java | 585 +
.../java/org/apache/joshua/lattice/Node.java | 158 +
.../lattice/NodeIdentifierComparator.java | 41 +
.../java/org/apache/joshua/lattice/package.html | 18 +
.../java/org/apache/joshua/metrics/BLEU.java | 569 +
.../org/apache/joshua/metrics/BLEU_SBP.java | 63 +
.../apache/joshua/metrics/EvaluationMetric.java | 398 +
.../apache/joshua/metrics/GradeLevelBLEU.java | 277 +
.../java/org/apache/joshua/metrics/METEOR.java | 235 +
.../joshua/metrics/MinimumChangeBLEU.java | 222 +
.../joshua/metrics/NewMetric.java.template | 134 +
.../java/org/apache/joshua/metrics/Precis.java | 333 +
.../joshua/metrics/PrecisMinusSourceBLEU.java | 182 +
.../org/apache/joshua/metrics/SourceBLEU.java | 107 +
.../java/org/apache/joshua/metrics/TER.java | 460 +
.../org/apache/joshua/metrics/TERMinusBLEU.java | 194 +
.../org/apache/joshua/metrics/TercomRunner.java | 115 +
.../org/apache/joshua/metrics/ZeroOneLoss.java | 88 +
src/main/java/org/apache/joshua/mira/MIRA.java | 160 +
.../java/org/apache/joshua/mira/MIRACore.java | 3117 +++
.../java/org/apache/joshua/mira/Optimizer.java | 643 +
.../joshua/oracle/OracleExtractionHG.java | 793 +
.../apache/joshua/oracle/OracleExtractor.java | 58 +
.../java/org/apache/joshua/oracle/SplitHg.java | 300 +
.../java/org/apache/joshua/oracle/package.html | 24 +
.../apache/joshua/pro/ClassifierInterface.java | 41 +
.../org/apache/joshua/pro/ClassifierMegaM.java | 121 +
.../apache/joshua/pro/ClassifierPerceptron.java | 109 +
.../org/apache/joshua/pro/ClassifierSVM.java | 140 +
.../java/org/apache/joshua/pro/Optimizer.java | 454 +
src/main/java/org/apache/joshua/pro/PRO.java | 159 +
.../java/org/apache/joshua/pro/PROCore.java | 3032 +++
.../org/apache/joshua/server/ServerThread.java | 138 +
.../org/apache/joshua/server/TcpServer.java | 65 +
.../joshua/subsample/AlignedSubsampler.java | 102 +
.../org/apache/joshua/subsample/Alignment.java | 83 +
.../org/apache/joshua/subsample/BiCorpus.java | 171 +
.../joshua/subsample/BiCorpusFactory.java | 68 +
.../org/apache/joshua/subsample/PhrasePair.java | 61 +
.../apache/joshua/subsample/PhraseReader.java | 35 +
.../apache/joshua/subsample/PhraseWriter.java | 79 +
.../org/apache/joshua/subsample/Subsampler.java | 227 +
.../apache/joshua/subsample/SubsamplerCLI.java | 121 +
.../org/apache/joshua/subsample/package.html | 25 +
.../org/apache/joshua/tools/GrammarPacker.java | 980 +
.../apache/joshua/tools/GrammarPackerCli.java | 155 +
.../org/apache/joshua/tools/LabelPhrases.java | 112 +
.../org/apache/joshua/tools/TestSetFilter.java | 376 +
.../java/org/apache/joshua/ui/Orientation.java | 23 +
.../org/apache/joshua/ui/StartupWindow.java | 87 +
src/main/java/org/apache/joshua/ui/package.html | 25 +
.../ui/tree_visualizer/DerivationTree.java | 103 +
.../ui/tree_visualizer/DerivationTreeEdge.java | 27 +
.../DerivationTreeTransformer.java | 117 +
.../ui/tree_visualizer/DerivationViewer.java | 128 +
.../tree_visualizer/DerivationViewerApplet.java | 51 +
.../apache/joshua/ui/tree_visualizer/Node.java | 59 +
.../ui/tree_visualizer/browser/Browser.java | 236 +
.../browser/DerivationTreeFrame.java | 253 +
.../browser/TranslationInfo.java | 56 +
.../joshua/ui/tree_visualizer/tree/Tree.java | 279 +
.../java/org/apache/joshua/util/Algorithms.java | 83 +
src/main/java/org/apache/joshua/util/Bits.java | 128 +
.../java/org/apache/joshua/util/BotMap.java | 94 +
src/main/java/org/apache/joshua/util/Cache.java | 186 +
.../java/org/apache/joshua/util/ChartSpan.java | 91 +
.../apache/joshua/util/CommandLineParser.java | 738 +
.../org/apache/joshua/util/CompareGrammars.java | 207 +
.../java/org/apache/joshua/util/Counted.java | 93 +
.../java/org/apache/joshua/util/Counts.java | 308 +
.../org/apache/joshua/util/ExtractTopCand.java | 179 +
.../org/apache/joshua/util/FileUtility.java | 307 +
.../org/apache/joshua/util/FormatUtils.java | 224 +
.../org/apache/joshua/util/IntegerPair.java | 36 +
.../java/org/apache/joshua/util/JoshuaEval.java | 625 +
.../java/org/apache/joshua/util/ListUtil.java | 95 +
src/main/java/org/apache/joshua/util/Lists.java | 567 +
.../apache/joshua/util/NBestListUtility.java | 74 +
src/main/java/org/apache/joshua/util/Ngram.java | 93 +
.../org/apache/joshua/util/NullIterator.java | 65 +
.../apache/joshua/util/PackedGrammarServer.java | 87 +
src/main/java/org/apache/joshua/util/Pair.java | 130 +
.../java/org/apache/joshua/util/Platform.java | 27 +
.../org/apache/joshua/util/QuietFormatter.java | 36 +
src/main/java/org/apache/joshua/util/Regex.java | 130 +
.../org/apache/joshua/util/ReverseOrder.java | 39 +
.../org/apache/joshua/util/SampledList.java | 69 +
.../org/apache/joshua/util/SocketUtility.java | 146 +
.../org/apache/joshua/util/StreamGobbler.java | 50 +
.../joshua/util/UnicodeCharacterName.java | 22466 +++++++++++++++++
.../apache/joshua/util/encoding/Analyzer.java | 235 +
.../joshua/util/encoding/EightBitQuantizer.java | 92 +
.../util/encoding/EncoderConfiguration.java | 160 +
.../joshua/util/encoding/EncoderFactory.java | 42 +
.../util/encoding/FeatureTypeAnalyzer.java | 249 +
.../joshua/util/encoding/FloatEncoder.java | 39 +
.../apache/joshua/util/encoding/IntEncoder.java | 39 +
.../util/encoding/PrimitiveFloatEncoder.java | 129 +
.../util/encoding/PrimitiveIntEncoder.java | 111 +
.../joshua/util/encoding/VariableQuantizer.java | 106 +
.../org/apache/joshua/util/io/BinaryIn.java | 104 +
.../org/apache/joshua/util/io/BinaryOut.java | 508 +
.../apache/joshua/util/io/IndexedReader.java | 150 +
.../org/apache/joshua/util/io/LineReader.java | 366 +
.../org/apache/joshua/util/io/NullReader.java | 63 +
.../joshua/util/io/ProgressInputStream.java | 82 +
.../java/org/apache/joshua/util/io/Reader.java | 40 +
.../java/org/apache/joshua/util/io/package.html | 18 +
.../java/org/apache/joshua/util/package.html | 18 +
.../util/quantization/BooleanQuantizer.java | 45 +
.../joshua/util/quantization/Quantizer.java | 45 +
.../quantization/QuantizerConfiguration.java | 119 +
.../util/quantization/QuantizerFactory.java | 50 +
.../util/quantization/StatelessQuantizer.java | 38 +
.../joshua/util/quantization/package-info.java | 19 +
.../joshua/zmert/IntermediateOptimizer.java | 992 +
.../java/org/apache/joshua/zmert/MertCore.java | 3197 +++
.../java/org/apache/joshua/zmert/ZMERT.java | 156 +
.../java/org/apache/joshua/zmert/package.html | 24 +
.../apache/joshua/corpus/CorpusArrayTest.java | 191 +
.../java/org/apache/joshua/corpus/SpanTest.java | 47 +
.../apache/joshua/corpus/VocabularyTest.java | 133 +
.../joshua/corpus/vocab/VocabularyTest.java | 186 +
.../ArtificialGrammarAndCorpusCreater.java | 130 +
.../joshua/decoder/DecoderThreadTest.java | 176 +
.../joshua/decoder/JoshuaDecoderTest.java | 83 +
.../joshua/decoder/TestConfigFileCreater.java | 184 +
.../apache/joshua/decoder/TranslationsTest.java | 87 +
.../decoder/ff/ArityPhrasePenaltyFFTest.java | 64 +
.../joshua/decoder/ff/lm/ArpaFileTest.java | 227 +
.../decoder/ff/lm/LanguageModelFFTest.java | 95 +
.../LMBerkeleySentenceProbablityTest.java | 47 +
.../lm/berkeley_lm/LMGrammarBerkeleyTest.java | 79 +
.../joshua/decoder/io/DeNormalizeTest.java | 273 +
.../decoder/io/TranslationRequestTest.java | 149 +
.../kbest_extraction/KBestExtractionTest.java | 80 +
.../joshua/decoder/phrase/CoverageTest.java | 140 +
.../ConstrainedPhraseDecodingTest.java | 77 +
.../phrase/decode/PhraseDecodingTest.java | 77 +
.../segment_file/AlmostTooLongSentenceTest.java | 96 +
.../decoder/segment_file/SentenceTest.java | 108 +
.../java/org/apache/joshua/lattice/ArcTest.java | 86 +
.../org/apache/joshua/lattice/LatticeTest.java | 197 +
.../org/apache/joshua/lattice/NodeTest.java | 108 +
.../org/apache/joshua/packed/Benchmark.java | 122 +
.../org/apache/joshua/packed/CountRules.java | 110 +
.../org/apache/joshua/packed/PrintRules.java | 199 +
src/test/java/org/apache/joshua/packed/README | 6 +
.../org/apache/joshua/packed/VocabTest.java | 52 +
.../java/org/apache/joshua/packed/packer.config | 6 +
.../java/org/apache/joshua/packed/small_grammar | 20000 +++++++++++++++
src/test/java/org/apache/joshua/packed/test.sh | 20 +
.../apache/joshua/system/AlignmentMapTest.java | 72 +
.../org/apache/joshua/system/KenLmTest.java | 95 +
.../system/MultithreadedTranslationTests.java | 164 +
.../joshua/system/StructuredOutputTest.java | 122 +
.../system/StructuredTranslationTest.java | 217 +
.../ui/tree_visualizer/tree/TreeTest.java | 111 +
.../java/org/apache/joshua/util/BitsTest.java | 187 +
.../java/org/apache/joshua/util/CacheTest.java | 53 +
.../java/org/apache/joshua/util/CountsTest.java | 98 +
.../org/apache/joshua/util/FormatUtilsTest.java | 78 +
.../org/apache/joshua/util/io/BinaryTest.java | 76 +
.../java/org/apache/joshua/zmert/BLEUTest.java | 132 +
test/joshua/corpus/CorpusArrayTest.java | 176 -
test/joshua/corpus/SpanTest.java | 46 -
test/joshua/corpus/vocab/VocabularyTest.java | 184 -
.../ArtificialGrammarAndCorpusCreater.java | 112 -
test/joshua/decoder/DecoderThreadTest.java | 178 -
test/joshua/decoder/JoshuaDecoderTest.java | 65 -
test/joshua/decoder/TestConfigFileCreater.java | 166 -
test/joshua/decoder/TranslationsTest.java | 66 -
.../decoder/ff/ArityPhrasePenaltyFFTest.java | 63 -
test/joshua/decoder/ff/lm/ArpaFileTest.java | 228 -
test/joshua/decoder/io/DeNormalizeTest.java | 255 -
.../decoder/io/TranslationRequestTest.java | 123 -
.../segment_file/AlmostTooLongSentenceTest.java | 78 -
.../decoder/segment_file/SentenceTest.java | 90 -
test/joshua/lattice/ArcTest.java | 82 -
test/joshua/lattice/LatticeTest.java | 194 -
test/joshua/lattice/NodeTest.java | 106 -
.../ui/tree_visualizer/tree/TreeTest.java | 93 -
test/joshua/util/BitsTest.java | 186 -
test/joshua/util/CacheTest.java | 35 -
test/joshua/util/CountsTest.java | 97 -
test/joshua/util/io/BinaryTest.java | 58 -
test/joshua/zmert/BLEUTest.java | 133 -
test/packed/Benchmark.java | 104 -
test/packed/CountRules.java | 92 -
test/packed/PrintRules.java | 177 -
test/packed/README | 6 -
test/packed/VocabTest.java | 33 -
test/packed/packer.config | 6 -
test/packed/small_grammar | 20000 ---------------
test/packed/test.sh | 20 -
thrax | 1 -
tst/joshua/corpus/VocabularyTest.java | 118 -
.../decoder/ff/lm/LanguageModelFFTest.java | 94 -
.../LMBerkeleySentenceProbablityTest.java | 29 -
.../lm/berkeley_lm/LMGrammarBerkeleyTest.java | 62 -
.../kbest_extraction/KBestExtractionTest.java | 80 -
.../ConstrainedPhraseDecodingTest.java | 77 -
.../phrase/decode/PhraseDecodingTest.java | 77 -
tst/joshua/system/AlignmentMapTest.java | 72 -
tst/joshua/system/KenLmTest.java | 95 -
.../system/MultithreadedTranslationTests.java | 141 -
tst/joshua/system/StructuredOutputTest.java | 121 -
.../system/StructuredTranslationTest.java | 217 -
tst/joshua/util/FormatUtilsTest.java | 78 -
637 files changed, 108876 insertions(+), 107065 deletions(-)
----------------------------------------------------------------------