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/08/29 16:49:23 UTC

[10/10] incubator-joshua git commit: Addressed todos from previous commits. Refactored entry points in Joshua to remove redundancy, this is a breaking change

Addressed todos from previous commits.  Refactored entry points in Joshua to remove redundancy, this is a breaking change


Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/f90cf3e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/f90cf3e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/f90cf3e4

Branch: refs/heads/7
Commit: f90cf3e4d947b32a27ef8f3d5f51d06677fd8d65
Parents: 0e87046
Author: Kellen Sunderland <ke...@amazon.com>
Authored: Thu Aug 25 11:50:43 2016 +0200
Committer: Kellen Sunderland <ke...@amazon.com>
Committed: Mon Aug 29 16:15:42 2016 +0200

----------------------------------------------------------------------
 .../org/apache/joshua/adagrad/AdaGradCore.java  |  2 +-
 .../java/org/apache/joshua/decoder/Decoder.java | 95 ++++----------------
 .../org/apache/joshua/decoder/DecoderTask.java  | 21 +----
 .../apache/joshua/decoder/JoshuaDecoder.java    |  2 +-
 .../java/org/apache/joshua/mira/MIRACore.java   |  2 +-
 .../java/org/apache/joshua/pro/PROCore.java     |  2 +-
 .../org/apache/joshua/util/io/LineReader.java   |  2 +-
 .../java/org/apache/joshua/zmert/MertCore.java  |  2 +-
 .../lm/berkeley_lm/LMGrammarBerkeleyTest.java   |  4 +-
 .../kbest_extraction/KBestExtractionTest.java   |  2 +-
 .../ConstrainedPhraseDecodingTest.java          |  2 +-
 .../phrase/decode/PhraseDecodingTest.java       |  2 +-
 .../apache/joshua/system/LmOovFeatureTest.java  |  2 +-
 .../system/MultithreadedTranslationTests.java   |  6 +-
 .../joshua/system/StructuredOutputTest.java     |  4 +-
 .../system/StructuredTranslationTest.java       |  4 +-
 .../decoder/DecoderServletContextListener.java  |  4 +-
 17 files changed, 36 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/main/java/org/apache/joshua/adagrad/AdaGradCore.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/main/java/org/apache/joshua/adagrad/AdaGradCore.java b/joshua-core/src/main/java/org/apache/joshua/adagrad/AdaGradCore.java
index 9dc81a4..396c4dc 100755
--- a/joshua-core/src/main/java/org/apache/joshua/adagrad/AdaGradCore.java
+++ b/joshua-core/src/main/java/org/apache/joshua/adagrad/AdaGradCore.java
@@ -486,7 +486,7 @@ public class AdaGradCore {
     // by default, load joshua decoder
     if (decoderCommand == null && fakeFileNameTemplate == null) {
       println("Loading Joshua decoder...", 1);
-      myDecoder = new Decoder(joshuaConfiguration, decoderConfigFileName + ".AdaGrad.orig");
+      myDecoder = new Decoder(joshuaConfiguration);
       println("...finished loading @ " + (new Date()), 1);
       println("");
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/main/java/org/apache/joshua/decoder/Decoder.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/main/java/org/apache/joshua/decoder/Decoder.java b/joshua-core/src/main/java/org/apache/joshua/decoder/Decoder.java
index 6070148..9cfb6eb 100644
--- a/joshua-core/src/main/java/org/apache/joshua/decoder/Decoder.java
+++ b/joshua-core/src/main/java/org/apache/joshua/decoder/Decoder.java
@@ -115,55 +115,14 @@ public class Decoder {
 
   public static int VERBOSE = 1;
 
-  // ===============================================================
-  // Constructors
-  // ===============================================================
-
   /**
    * Constructor method that creates a new decoder using the specified configuration file.
    *
    * @param joshuaConfiguration a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
-   * @param configFile name of configuration file.
-   */
-  public Decoder(JoshuaConfiguration joshuaConfiguration, String configFile) {
-    this(joshuaConfiguration);
-    this.initialize(configFile);
-  }
-
-  /**
-   * Factory method that creates a new decoder using the specified configuration file.
-   *
-   * @param configFile Name of configuration file.
-   * @return a configured {@link org.apache.joshua.decoder.Decoder}
    */
-  public static Decoder createDecoder(String configFile) {
-    JoshuaConfiguration joshuaConfiguration = new JoshuaConfiguration();
-    return new Decoder(joshuaConfiguration, configFile);
-  }
-
-  /**
-   * Constructs an uninitialized decoder for use in testing.
-   * <p>
-   * This method is private because it should only ever be called by the
-   * {@link #getUninitalizedDecoder()} method to provide an uninitialized decoder for use in
-   * testing.
-   */
-  private Decoder(JoshuaConfiguration joshuaConfiguration) {
+  public Decoder(JoshuaConfiguration joshuaConfiguration) {
     this.joshuaConfiguration = joshuaConfiguration;
-
-    resetGlobalState();
-  }
-
-  /**
-   * Gets an uninitialized decoder for use in testing.
-   * <p>
-   * This method is called by unit tests or any outside packages (e.g., MERT) relying on the
-   * decoder.
-   * @param joshuaConfiguration a {@link org.apache.joshua.decoder.JoshuaConfiguration} object
-   * @return an uninitialized decoder for use in testing
-   */
-  static public Decoder getUninitalizedDecoder(JoshuaConfiguration joshuaConfiguration) {
-    return new Decoder(joshuaConfiguration);
+    this.initialize();
   }
 
   /**
@@ -223,13 +182,8 @@ public class Decoder {
    * @return the sentence {@link org.apache.joshua.decoder.Translation}
    */
   public Translation decode(Sentence sentence) {
-    try {
-      DecoderTask decoderTask = new DecoderTask(this.grammars, Decoder.weights, this.featureFunctions, joshuaConfiguration);
-      return decoderTask.translate(sentence);
-    } catch (IOException e) {
-      throw new RuntimeException(String.format(
-              "Input %d: FATAL UNCAUGHT EXCEPTION: %s", sentence.id(), e.getMessage()), e);
-    }
+    DecoderTask decoderTask = new DecoderTask(this.grammars, this.featureFunctions, joshuaConfiguration);
+    return decoderTask.translate(sentence);
   }
 
   /**
@@ -256,9 +210,8 @@ public class Decoder {
     try {
       int columnID = 0;
 
-      BufferedWriter writer = FileUtility.getWriteFileStream(outputFile);
-      LineReader reader = new LineReader(template);
-      try {
+      try (LineReader reader = new LineReader(template);
+           BufferedWriter writer = FileUtility.getWriteFileStream(outputFile)) {
         for (String line : reader) {
           line = line.trim();
           if (Regex.commentOrEmptyLine.matches(line) || line.contains("=")) {
@@ -271,7 +224,7 @@ public class Decoder {
             StringBuilder newSent = new StringBuilder();
             if (!Regex.floatingNumber.matches(fds[fds.length - 1])) {
               throw new IllegalArgumentException("last field is not a number; the field is: "
-                  + fds[fds.length - 1]);
+                      + fds[fds.length - 1]);
             }
 
             if (newDiscriminativeModel != null && "discriminative".equals(fds[0])) {
@@ -295,9 +248,6 @@ public class Decoder {
             writer.newLine();
           }
         }
-      } finally {
-        reader.close();
-        writer.close();
       }
 
       if (newWeights != null && columnID != newWeights.length) {
@@ -309,20 +259,14 @@ public class Decoder {
     }
   }
 
-  // ===============================================================
-  // Initialization Methods
-  // ===============================================================
-
   /**
    * Initialize all parts of the JoshuaDecoder.
-   *
-   * @param configFile File containing configuration options
-   * @return An initialized decoder
    */
-  public Decoder initialize(String configFile) {
+  private void initialize() {
     try {
 
       long pre_load_time = System.currentTimeMillis();
+      resetGlobalState();
 
       /* Weights can be listed in a separate file (denoted by parameter "weights-file") or directly
        * in the Joshua config file. Config file values take precedent.
@@ -397,21 +341,16 @@ public class Decoder {
             (System.currentTimeMillis() - pre_sort_time) / 1000);
       }
 
-      // Create the threads
-      //TODO: (kellens) see if we need to wait until initialized before decoding
     } catch (IOException e) {
       LOG.warn(e.getMessage(), e);
     }
-
-    return this;
   }
 
   /**
    * Initializes translation grammars Retained for backward compatibility
    *
-   * @param ownersSeen Records which PhraseModelFF's have been instantiated (one is needed for each
-   *          owner)
-   * @throws IOException
+   * @throws IOException Several grammar elements read from disk that can
+   * cause IOExceptions.
    */
   private void initializeTranslationGrammars() throws IOException {
 
@@ -483,9 +422,8 @@ public class Decoder {
       String goalNT = FormatUtils.cleanNonTerminal(joshuaConfiguration.goal_symbol);
       String defaultNT = FormatUtils.cleanNonTerminal(joshuaConfiguration.default_non_terminal);
 
-      //FIXME: too many arguments
-      String ruleString = String.format("[%s] ||| [%s,1] <eps> ||| [%s,1] ||| ", goalNT, goalNT, defaultNT,
-          goalNT, defaultNT);
+      //FIXME: arguments changed to match string format on best effort basis.  Author please review.
+      String ruleString = String.format("[%s] ||| [%s,1] <eps> ||| [%s,1] ||| ", goalNT, defaultNT, defaultNT);
 
       Rule rule = reader.parseLine(ruleString);
       latticeGrammar.addRule(rule);
@@ -589,10 +527,8 @@ public class Decoder {
    *
    * Weights for features are listed separately.
    *
-   * @throws IOException
-   *
    */
-  private void initializeFeatureFunctions() throws IOException {
+  private void initializeFeatureFunctions() {
 
     for (String featureLine : joshuaConfiguration.features) {
       // line starts with NAME, followed by args
@@ -623,9 +559,8 @@ public class Decoder {
    * Searches a list of predefined paths for classes, and returns the first one found. Meant for
    * instantiating feature functions.
    *
-   * @param name
+   * @param featureName Class name of the feature to return.
    * @return the class, found in one of the search paths
-   * @throws ClassNotFoundException
    */
   private Class<?> getFeatureFunctionClass(String featureName) {
     Class<?> clas = null;

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/main/java/org/apache/joshua/decoder/DecoderTask.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/main/java/org/apache/joshua/decoder/DecoderTask.java b/joshua-core/src/main/java/org/apache/joshua/decoder/DecoderTask.java
index b694c05..0c7a76b 100644
--- a/joshua-core/src/main/java/org/apache/joshua/decoder/DecoderTask.java
+++ b/joshua-core/src/main/java/org/apache/joshua/decoder/DecoderTask.java
@@ -18,13 +18,11 @@
  */
 package org.apache.joshua.decoder;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.joshua.decoder.chart_parser.Chart;
 import org.apache.joshua.decoder.ff.FeatureFunction;
-import org.apache.joshua.decoder.ff.FeatureVector;
 import org.apache.joshua.decoder.ff.SourceDependentFF;
 import org.apache.joshua.decoder.ff.tm.Grammar;
 import org.apache.joshua.decoder.hypergraph.ForestWalker;
@@ -60,13 +58,8 @@ public class DecoderTask {
   private final List<Grammar> allGrammars;
   private final List<FeatureFunction> featureFunctions;
 
-
-  // ===============================================================
-  // Constructor
-  // ===============================================================
-  //TODO: (kellens) why is weights unused?
-  public DecoderTask(List<Grammar> grammars, FeatureVector weights,
-                     List<FeatureFunction> featureFunctions, JoshuaConfiguration joshuaConfiguration) throws IOException {
+  public DecoderTask(List<Grammar> grammars, List<FeatureFunction> featureFunctions,
+                       JoshuaConfiguration joshuaConfiguration) {
 
     this.joshuaConfiguration = joshuaConfiguration;
     this.allGrammars = grammars;
@@ -81,10 +74,6 @@ public class DecoderTask {
     }
   }
 
-  // ===============================================================
-  // Methods
-  // ===============================================================
-
   /**
    * Translate a sentence.
    * 
@@ -116,12 +105,12 @@ public class DecoderTask {
     if (joshuaConfiguration.segment_oovs)
       sentence.segmentOOVs(grammars);
 
-    /**
+    /*
      * Joshua supports (as of September 2014) both phrase-based and hierarchical decoding. Here
      * we build the appropriate chart. The output of both systems is a hypergraph, which is then
      * used for further processing (e.g., k-best extraction).
      */
-    HyperGraph hypergraph = null;
+    HyperGraph hypergraph;
     try {
 
       if (joshuaConfiguration.search_algorithm.equals("stack")) {
@@ -153,8 +142,6 @@ public class DecoderTask {
       return new Translation(sentence, hypergraph, featureFunctions, joshuaConfiguration);
     }
 
-    /*****************************************************************************************/
-
     /*
      * Synchronous parsing.
      * 

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/main/java/org/apache/joshua/decoder/JoshuaDecoder.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/main/java/org/apache/joshua/decoder/JoshuaDecoder.java b/joshua-core/src/main/java/org/apache/joshua/decoder/JoshuaDecoder.java
index d10de8c..f25590c 100644
--- a/joshua-core/src/main/java/org/apache/joshua/decoder/JoshuaDecoder.java
+++ b/joshua-core/src/main/java/org/apache/joshua/decoder/JoshuaDecoder.java
@@ -66,7 +66,7 @@ public class JoshuaDecoder {
     joshuaConfiguration.sanityCheck();
 
     /* Step-1: initialize the decoder, test-set independent */
-    Decoder decoder = new Decoder(joshuaConfiguration, userArgs.getConfigFile());
+    Decoder decoder = new Decoder(joshuaConfiguration);
 
     LOG.info("Model loading took {} seconds", (System.currentTimeMillis() - startTime) / 1000);
     LOG.info("Memory used {} MB", ((Runtime.getRuntime().totalMemory()

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/main/java/org/apache/joshua/mira/MIRACore.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/main/java/org/apache/joshua/mira/MIRACore.java b/joshua-core/src/main/java/org/apache/joshua/mira/MIRACore.java
index 42dd995..78b815a 100755
--- a/joshua-core/src/main/java/org/apache/joshua/mira/MIRACore.java
+++ b/joshua-core/src/main/java/org/apache/joshua/mira/MIRACore.java
@@ -484,7 +484,7 @@ public class MIRACore {
     // by default, load joshua decoder
     if (decoderCommand == null && fakeFileNameTemplate == null) {
       println("Loading Joshua decoder...", 1);
-      myDecoder = new Decoder(joshuaConfiguration, decoderConfigFileName + ".MIRA.orig");
+      myDecoder = new Decoder(joshuaConfiguration);
       println("...finished loading @ " + (new Date()), 1);
       println("");
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/main/java/org/apache/joshua/pro/PROCore.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/main/java/org/apache/joshua/pro/PROCore.java b/joshua-core/src/main/java/org/apache/joshua/pro/PROCore.java
index ec23e0a..39b34a5 100755
--- a/joshua-core/src/main/java/org/apache/joshua/pro/PROCore.java
+++ b/joshua-core/src/main/java/org/apache/joshua/pro/PROCore.java
@@ -477,7 +477,7 @@ public class PROCore {
     // by default, load joshua decoder
     if (decoderCommand == null && fakeFileNameTemplate == null) {
       println("Loading Joshua decoder...", 1);
-      myDecoder = new Decoder(joshuaConfiguration, decoderConfigFileName + ".PRO.orig");
+      myDecoder = new Decoder(joshuaConfiguration);
       println("...finished loading @ " + (new Date()), 1);
       println("");
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/main/java/org/apache/joshua/util/io/LineReader.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/main/java/org/apache/joshua/util/io/LineReader.java b/joshua-core/src/main/java/org/apache/joshua/util/io/LineReader.java
index 5122994..d63763d 100644
--- a/joshua-core/src/main/java/org/apache/joshua/util/io/LineReader.java
+++ b/joshua-core/src/main/java/org/apache/joshua/util/io/LineReader.java
@@ -39,7 +39,7 @@ import org.apache.joshua.decoder.Decoder;
  * @author wren ng thornton wren@users.sourceforge.net
  * @author Matt Post post@cs.jhu.edu
  */
-public class LineReader implements Reader<String> {
+public class LineReader implements Reader<String>, AutoCloseable {
 
   /*
    * Note: charset name is case-agnostic "UTF-8" is the canonical name "UTF8", "unicode-1-1-utf-8"

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/main/java/org/apache/joshua/zmert/MertCore.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/main/java/org/apache/joshua/zmert/MertCore.java b/joshua-core/src/main/java/org/apache/joshua/zmert/MertCore.java
index c0d470d..4110c97 100644
--- a/joshua-core/src/main/java/org/apache/joshua/zmert/MertCore.java
+++ b/joshua-core/src/main/java/org/apache/joshua/zmert/MertCore.java
@@ -487,7 +487,7 @@ public class MertCore {
 
     if (decoderCommand == null && fakeFileNameTemplate == null) {
       println("Loading Joshua decoder...", 1);
-      myDecoder = new Decoder(joshuaConfiguration, decoderConfigFileName + ".ZMERT.orig");
+      myDecoder = new Decoder(joshuaConfiguration);
       println("...finished loading @ " + (new Date()), 1);
       println("");
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/test/java/org/apache/joshua/decoder/ff/lm/berkeley_lm/LMGrammarBerkeleyTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/ff/lm/berkeley_lm/LMGrammarBerkeleyTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/ff/lm/berkeley_lm/LMGrammarBerkeleyTest.java
index cf04a3d..253f57d 100644
--- a/joshua-core/src/test/java/org/apache/joshua/decoder/ff/lm/berkeley_lm/LMGrammarBerkeleyTest.java
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/ff/lm/berkeley_lm/LMGrammarBerkeleyTest.java
@@ -60,7 +60,7 @@ public class LMGrammarBerkeleyTest {
     joshuaConfig = new JoshuaConfiguration();
     joshuaConfig.processCommandLineOptions(OPTIONS);
     joshuaConfig.features.add("LanguageModel -lm_type berkeleylm -lm_order 2 -lm_file " + lmFile);
-    decoder = new Decoder(joshuaConfig, null);
+    decoder = new Decoder(joshuaConfig);
     final String translation = decode(INPUT).toString();
     assertEquals(translation, EXPECTED_OUTPUT);
   }
@@ -75,7 +75,7 @@ public class LMGrammarBerkeleyTest {
     joshuaConfig = new JoshuaConfiguration();
     joshuaConfig.processCommandLineOptions(OPTIONS);
     joshuaConfig.features.add("LanguageModel -lm_type berkeleylm -oov_feature -lm_order 2 -lm_file src/test/resources/berkeley_lm/lm");
-    decoder = new Decoder(joshuaConfig, null);
+    decoder = new Decoder(joshuaConfig);
     final String translation = decode(INPUT).toString();
     assertEquals(translation, EXPECTED_OUTPUT_WITH_OOV);
   }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/test/java/org/apache/joshua/decoder/kbest_extraction/KBestExtractionTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/kbest_extraction/KBestExtractionTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/kbest_extraction/KBestExtractionTest.java
index f2cbe7f..172632b 100644
--- a/joshua-core/src/test/java/org/apache/joshua/decoder/kbest_extraction/KBestExtractionTest.java
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/kbest_extraction/KBestExtractionTest.java
@@ -58,7 +58,7 @@ public class KBestExtractionTest {
     joshuaConfig = new JoshuaConfiguration();
     joshuaConfig.readConfigFile(CONFIG);
     joshuaConfig.outputFormat = "%i ||| %s ||| %c";
-    KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig, ""));
+    KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig));
   }
 
   @AfterMethod

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/test/java/org/apache/joshua/decoder/phrase/constrained/ConstrainedPhraseDecodingTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/phrase/constrained/ConstrainedPhraseDecodingTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/phrase/constrained/ConstrainedPhraseDecodingTest.java
index 8a68ab7..d81c522 100644
--- a/joshua-core/src/test/java/org/apache/joshua/decoder/phrase/constrained/ConstrainedPhraseDecodingTest.java
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/phrase/constrained/ConstrainedPhraseDecodingTest.java
@@ -52,7 +52,7 @@ public class ConstrainedPhraseDecodingTest {
   public void setUp() throws Exception {
     joshuaConfig = new JoshuaConfiguration();
     joshuaConfig.readConfigFile(CONFIG);
-    KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig, ""));
+    KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig));
   }
 
   @AfterMethod

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/test/java/org/apache/joshua/decoder/phrase/decode/PhraseDecodingTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/phrase/decode/PhraseDecodingTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/phrase/decode/PhraseDecodingTest.java
index 625fe0c..66515de 100644
--- a/joshua-core/src/test/java/org/apache/joshua/decoder/phrase/decode/PhraseDecodingTest.java
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/phrase/decode/PhraseDecodingTest.java
@@ -48,7 +48,7 @@ public class PhraseDecodingTest {
   public void setUp() throws Exception {
     joshuaConfig = new JoshuaConfiguration();
     joshuaConfig.readConfigFile(CONFIG);
-    KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig, ""));
+    KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig));
   }
 
   @AfterMethod

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/test/java/org/apache/joshua/system/LmOovFeatureTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/system/LmOovFeatureTest.java b/joshua-core/src/test/java/org/apache/joshua/system/LmOovFeatureTest.java
index 84789ce..d097d62 100644
--- a/joshua-core/src/test/java/org/apache/joshua/system/LmOovFeatureTest.java
+++ b/joshua-core/src/test/java/org/apache/joshua/system/LmOovFeatureTest.java
@@ -45,7 +45,7 @@ public class LmOovFeatureTest {
     joshuaConfig = new JoshuaConfiguration();
     joshuaConfig.readConfigFile(CONFIG);
     joshuaConfig.outputFormat = "%f | %c";
-    decoder = new Decoder(joshuaConfig, "");
+    decoder = new Decoder(joshuaConfig);
   }
 
   @AfterMethod

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/test/java/org/apache/joshua/system/MultithreadedTranslationTests.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/system/MultithreadedTranslationTests.java b/joshua-core/src/test/java/org/apache/joshua/system/MultithreadedTranslationTests.java
index 8192cb3..10872d0 100644
--- a/joshua-core/src/test/java/org/apache/joshua/system/MultithreadedTranslationTests.java
+++ b/joshua-core/src/test/java/org/apache/joshua/system/MultithreadedTranslationTests.java
@@ -83,11 +83,7 @@ public class MultithreadedTranslationTests {
                                               // concurrency errors in
                                               // underlying
                                               // data-structures.
-    this.decoder = new Decoder(joshuaConfig, ""); // Second argument
-                                                  // (configFile)
-                                                  // is not even used by the
-                                                  // constructor/initialize.
-
+    this.decoder = new Decoder(joshuaConfig);
     previousLogLevel = Decoder.VERBOSE;
     Decoder.VERBOSE = 0;
   }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/test/java/org/apache/joshua/system/StructuredOutputTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/system/StructuredOutputTest.java b/joshua-core/src/test/java/org/apache/joshua/system/StructuredOutputTest.java
index 1c9a6fe..e4dd435 100644
--- a/joshua-core/src/test/java/org/apache/joshua/system/StructuredOutputTest.java
+++ b/joshua-core/src/test/java/org/apache/joshua/system/StructuredOutputTest.java
@@ -75,9 +75,7 @@ public class StructuredOutputTest {
     joshuaConfig.weights.add("pt_5 -1");
     joshuaConfig.weights.add("glue_0 -1");
     joshuaConfig.weights.add("OOVPenalty 2");
-    decoder = new Decoder(joshuaConfig, ""); // second argument (configFile
-                                             // is not even used by the
-                                             // constructor/initialize)
+    decoder = new Decoder(joshuaConfig);
   }
 
   @AfterMethod

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-core/src/test/java/org/apache/joshua/system/StructuredTranslationTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/system/StructuredTranslationTest.java b/joshua-core/src/test/java/org/apache/joshua/system/StructuredTranslationTest.java
index 5a4f128..308d517 100644
--- a/joshua-core/src/test/java/org/apache/joshua/system/StructuredTranslationTest.java
+++ b/joshua-core/src/test/java/org/apache/joshua/system/StructuredTranslationTest.java
@@ -93,9 +93,7 @@ public class StructuredTranslationTest {
     joshuaConfig.weights.add("pt_5 -1");
     joshuaConfig.weights.add("glue_0 -1");
     joshuaConfig.weights.add("OOVPenalty 1");
-    decoder = new Decoder(joshuaConfig, ""); // second argument (configFile
-                                             // is not even used by the
-                                             // constructor/initialize)
+    decoder = new Decoder(joshuaConfig);
   }
 
   @AfterMethod

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f90cf3e4/joshua-web/src/main/java/org/apache/joshua/decoder/DecoderServletContextListener.java
----------------------------------------------------------------------
diff --git a/joshua-web/src/main/java/org/apache/joshua/decoder/DecoderServletContextListener.java b/joshua-web/src/main/java/org/apache/joshua/decoder/DecoderServletContextListener.java
index 3860f7e..933911f 100644
--- a/joshua-web/src/main/java/org/apache/joshua/decoder/DecoderServletContextListener.java
+++ b/joshua-web/src/main/java/org/apache/joshua/decoder/DecoderServletContextListener.java
@@ -35,10 +35,10 @@ public class DecoderServletContextListener implements ServletContextListener {
         String argsLine = sce.getServletContext().getInitParameter("decoderArgsLine");
         try {
             JoshuaConfiguration joshuaConfiguration = new JoshuaConfiguration();
-            ArgsParser userArgs = new ArgsParser(argsLine.split(" "), joshuaConfiguration);
+            new ArgsParser(argsLine.split(" "), joshuaConfiguration);
             joshuaConfiguration.use_structured_output = true;
             joshuaConfiguration.sanityCheck();
-            Decoder decoder = new Decoder(joshuaConfiguration, userArgs.getConfigFile());
+            Decoder decoder = new Decoder(joshuaConfiguration);
             sce.getServletContext().setAttribute(DECODER_CONTEXT_ATTRIBUTE_NAME, decoder);
         } catch (Exception ex) {
             Throwables.propagate(ex);