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/20 02:43:35 UTC

[11/15] incubator-joshua git commit: fixed distortion computation to work with new format

fixed distortion computation to work with new format

code now produces a translation on my test case, though it's not the correct one


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

Branch: refs/heads/JOSHUA-284
Commit: 5719c8cff728499bffd1053462351340f1d91353
Parents: 9b73d61
Author: Matt Post <po...@cs.jhu.edu>
Authored: Fri Aug 19 13:17:21 2016 -0500
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Fri Aug 19 13:17:21 2016 -0500

----------------------------------------------------------------------
 .../org/apache/joshua/decoder/ff/phrase/Distortion.java | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/5719c8cf/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 f9e6a29..072162b 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,12 +56,14 @@ 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.BEGIN_RULE && rule != Hypothesis.END_RULE) {
-        int start_point = j - rule.getFrench().length + rule.getArity();
+    if (rule == Hypothesis.MONO_RULE || rule == Hypothesis.SWAP_RULE) {
+//        int start_point = j - rule.getFrench().length + rule.getArity();
+//        int jump_size = Math.abs(tailNodes.get(0).j - start_point);
 
-        int jump_size = Math.abs(tailNodes.get(0).j - start_point);
-//        acc.add(name, -jump_size);
-        acc.add(denseFeatureIndex, -jump_size); 
+      int start_point = tailNodes.get(rule == Hypothesis.MONO_RULE ? 0 : 1).j;
+      int jump_size = Math.abs(j - start_point);
+
+      acc.add(denseFeatureIndex, -jump_size); 
     }
     
 //    System.err.println(String.format("DISTORTION(%d, %d) from %d = %d", i, j, tailNodes != null ? tailNodes.get(0).j : -1, jump_size));