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/09/14 09:11:34 UTC

[12/43] incubator-joshua git commit: missed obvious simplification

missed obvious simplification


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

Branch: refs/heads/7
Commit: ca0411acea805cc14086d91a43782f47d9ad4557
Parents: f7cf2e0
Author: Matt Post <po...@cs.jhu.edu>
Authored: Thu Sep 8 16:47:41 2016 -0400
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Thu Sep 8 16:47:41 2016 -0400

----------------------------------------------------------------------
 .../joshua/decoder/ff/phrase/Distortion.java    | 41 +++++++-------------
 1 file changed, 14 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/ca0411ac/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 dd22a9d..8ba9e35 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
@@ -56,37 +56,24 @@ public class Distortion extends StatelessFF {
   public DPState compute(Rule rule, List<HGNode> tailNodes, int i, int j, SourcePath sourcePath,
       Sentence sentence, Accumulator acc) {
 
-    if (rule == Hypothesis.INORDER_RULE || rule == Hypothesis.INVERTED_RULE) {
-//        int start_point = j - rule.getFrench().length + rule.getArity();
-//        int jump_size = Math.abs(tailNodes.get(0).j - start_point);
+    if (rule == Hypothesis.INORDER_RULE) {
+      int last_phrase_end = tailNodes.get(0).j;
+      int new_phrase_start = tailNodes.get(1).i;
+      int jump_size = Math.abs(last_phrase_end - new_phrase_start);
 
-      if (rule == Hypothesis.INORDER_RULE) {
-        int last_phrase_end = tailNodes.get(0).j;
-        int new_phrase_start = tailNodes.get(1).i;
-        int jump_size = Math.abs(last_phrase_end - new_phrase_start);
-        
-//        int start_point = j - tailNodes.get(1).getHyperEdges().get(0).getRule().getFrench().length;
-//        int last_point = tailNodes.get(0).j;
-//        int jump_size = Math.abs(start_point - last_point);
-      
-//        System.err.println(String.format("DISTORTION_mono(%d -> %d) = %d", 
-//            last_phrase_end, new_phrase_start, jump_size));
+      //        System.err.println(String.format("DISTORTION_mono(%d -> %d) = %d", 
+      //            last_phrase_end, new_phrase_start, jump_size));
 
-        acc.add(denseFeatureIndex, -jump_size);
-      } else {
-        int last_phrase_end = tailNodes.get(1).j;
-        int new_phrase_start = tailNodes.get(0).i;
-        int jump_size = Math.abs(last_phrase_end - new_phrase_start);
+      acc.add(denseFeatureIndex, -jump_size);
+    } else if (rule == Hypothesis.INVERTED_RULE) {
+      int last_phrase_end = tailNodes.get(1).j;
+      int new_phrase_start = tailNodes.get(0).i;
+      int jump_size = Math.abs(last_phrase_end - new_phrase_start);
 
-//        int start_point = j - tailNodes.get(0).getHyperEdges().get(0).getRule().getFrench().length;
-//        int last_point = tailNodes.get(1).j;
-//        int jump_size = Math.abs(start_point - last_point);
-      
-//        System.err.println(String.format("DISTORTION_swap(%d -> %d) = %d", 
-//            last_phrase_end, new_phrase_start, jump_size));
+      //        System.err.println(String.format("DISTORTION_swap(%d -> %d) = %d", 
+      //            last_phrase_end, new_phrase_start, jump_size));
 
-        acc.add(denseFeatureIndex, -jump_size);    
-      }
+      acc.add(denseFeatureIndex, -jump_size);    
     }
     
     return null;