Permalink
Browse files

Joshua now works with no arguments (sensible defaults, just parses wi…

…th glue grammar
  • Loading branch information...
1 parent bd92b19 commit 35171cbf240c3158ed3e804285a5a89f9e0184b1 @mjpost mjpost committed Jun 21, 2012
Showing with 36 additions and 31 deletions.
  1. +2 −2 joshua-decoder
  2. +3 −4 src/joshua/decoder/JoshuaConfiguration.java
  3. +31 −25 src/joshua/decoder/JoshuaDecoder.java
View
@@ -9,8 +9,6 @@
#
# The default amount of memory is 4gb.
-set -u
-
NUM_ARGS=0
E_OPTERROR=1
@@ -24,6 +22,8 @@ if [[ $1 == "-m" ]]; then
shift
fi
+set -u
+
java -Xmx${mem} \
-cp $JOSHUA/bin:$JOSHUA/thrax/bin/thrax.jar:$JOSHUA/lib/berkeleylm.jar \
-Dfile.encoding=utf8 \
@@ -57,19 +57,18 @@
// Default symbols. The symbol here should be enclosed in square brackets.
public static String default_non_terminal = "[X]";
- public static String goal_symbol = "[S]";
+ public static String goal_symbol = "[GOAL]";
public static boolean use_sent_specific_tm = false;
public static boolean dense_features = true;
public static String tm_file = null;
- public static String tm_format = null;
+ public static String tm_format = "thrax";
- // TODO: default to glue grammar provided with Joshua
// TODO: support multiple glue grammars
public static String glue_file = null;
- public static String glue_format = null;
+ public static String glue_format = "thrax";
// syntax-constrained decoding
public static boolean constrain_parse = false;
@@ -348,8 +348,12 @@ private void initializeLanguageModel() throws IOException {
private void initializeGlueGrammar() throws IOException {
logger.info("Constructing glue grammar...");
- MemoryBasedBatchGrammar gr =
- new MemoryBasedBatchGrammar(JoshuaConfiguration.glue_format, JoshuaConfiguration.glue_file,
+ MemoryBasedBatchGrammar gr = (JoshuaConfiguration.glue_file == null)
+ ? new MemoryBasedBatchGrammar(JoshuaConfiguration.glue_format,
+ System.getenv().get("JOSHUA") + "/data/" + "glue-grammar",
+ JoshuaConfiguration.glue_owner, JoshuaConfiguration.default_non_terminal, -1,
+ JoshuaConfiguration.oov_feature_cost)
+ : new MemoryBasedBatchGrammar(JoshuaConfiguration.glue_format, JoshuaConfiguration.glue_file,
JoshuaConfiguration.glue_owner, JoshuaConfiguration.default_non_terminal, -1,
JoshuaConfiguration.oov_feature_cost);
@@ -511,11 +515,11 @@ public static void main(String[] args) throws IOException {
long startTime = System.currentTimeMillis();
- if (args.length < 1) {
- System.out.println("Usage: java " + JoshuaDecoder.class.getName()
- + " -c configFile [other args]");
- System.exit(1);
- }
+ // if (args.length < 1) {
+ // System.out.println("Usage: java " + JoshuaDecoder.class.getName()
+ // + " -c configFile [other args]");
+ // System.exit(1);
+ // }
String configFile = null;
String testFile = "-";
@@ -531,32 +535,34 @@ public static void main(String[] args) throws IOException {
// argument; if it starts with a hyphen, the new format has
// been invoked.
- if (args[0].startsWith("-")) {
+ if (args.length >= 1) {
+ if (args[0].startsWith("-")) {
- // Search for the configuration file
- for (int i = 0; i < args.length; i++) {
- if (args[i].equals("-c") || args[i].equals("-config")) {
+ // Search for the configuration file
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("-c") || args[i].equals("-config")) {
- configFile = args[i + 1].trim();
- JoshuaConfiguration.readConfigFile(configFile);
- JoshuaConfiguration.processCommandLineOptions(args);
+ configFile = args[i + 1].trim();
+ JoshuaConfiguration.readConfigFile(configFile);
+ JoshuaConfiguration.processCommandLineOptions(args);
- break;
- }
- }
+ break;
+ }
+ }
- oracleFile = JoshuaConfiguration.oracleFile;
+ oracleFile = JoshuaConfiguration.oracleFile;
- } else {
+ } else {
- configFile = args[0].trim();
+ configFile = args[0].trim();
- JoshuaConfiguration.readConfigFile(configFile);
+ JoshuaConfiguration.readConfigFile(configFile);
- if (args.length >= 2) testFile = args[1].trim();
- if (args.length >= 3) nbestFile = args[2].trim();
- if (args.length == 4) oracleFile = args[3].trim();
- }
+ if (args.length >= 2) testFile = args[1].trim();
+ if (args.length >= 3) nbestFile = args[2].trim();
+ if (args.length == 4) oracleFile = args[3].trim();
+ }
+ }
/* Step-0: some sanity checking */
JoshuaConfiguration.sanityCheck();

0 comments on commit 35171cb

Please sign in to comment.