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/25 18:08:09 UTC

[05/15] incubator-joshua git commit: GrammarReader iterator now initialized in constructor

GrammarReader iterator now initialized in constructor


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

Branch: refs/heads/master
Commit: 210573bbdf8ca6c1633e2f11f21fd03cf33473ca
Parents: 4781405
Author: Matt Post <po...@cs.jhu.edu>
Authored: Wed May 25 01:08:44 2016 +0200
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Wed May 25 01:08:44 2016 +0200

----------------------------------------------------------------------
 src/joshua/decoder/ff/tm/GrammarReader.java            | 13 ++-----------
 .../ff/tm/hash_based/MemoryBasedBatchGrammar.java      |  1 -
 2 files changed, 2 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/210573bb/src/joshua/decoder/ff/tm/GrammarReader.java
----------------------------------------------------------------------
diff --git a/src/joshua/decoder/ff/tm/GrammarReader.java b/src/joshua/decoder/ff/tm/GrammarReader.java
index 7edab7c..3b973a2 100644
--- a/src/joshua/decoder/ff/tm/GrammarReader.java
+++ b/src/joshua/decoder/ff/tm/GrammarReader.java
@@ -51,18 +51,9 @@ public abstract class GrammarReader<R extends Rule> implements Iterable<R>, Iter
     this.fileName = null;
   }
 
-  public GrammarReader(String fileName) {
+  public GrammarReader(String fileName) throws IOException {
     this.fileName = fileName;
-  }
-
-  public void initialize() {
-    try {
-      this.reader = new LineReader(fileName);
-    } catch (IOException e) {
-      throw new RuntimeException("Error opening translation model file: " + fileName + "\n"
-          + (null != e.getMessage() ? e.getMessage() : "No details available. Sorry."), e);
-    }
-
+    this.reader = new LineReader(fileName);
     Decoder.LOG(1, String.format("Reading grammar from file %s...", fileName));
     numRulesRead = 0;
     advanceReader();

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/210573bb/src/joshua/decoder/ff/tm/hash_based/MemoryBasedBatchGrammar.java
----------------------------------------------------------------------
diff --git a/src/joshua/decoder/ff/tm/hash_based/MemoryBasedBatchGrammar.java b/src/joshua/decoder/ff/tm/hash_based/MemoryBasedBatchGrammar.java
index e85ce09..f0c9ac8 100644
--- a/src/joshua/decoder/ff/tm/hash_based/MemoryBasedBatchGrammar.java
+++ b/src/joshua/decoder/ff/tm/hash_based/MemoryBasedBatchGrammar.java
@@ -111,7 +111,6 @@ public class MemoryBasedBatchGrammar extends AbstractGrammar {
     // ==== loading grammar
     this.modelReader = createReader(formatKeyword, grammarFile);
     if (modelReader != null) {
-      modelReader.initialize();
       for (Rule rule : modelReader)
         if (rule != null) {
           addRule(rule);