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/23 22:17:19 UTC
[02/50] [abbrv] incubator-joshua git commit: fixed computation of
distortion
fixed computation of distortion
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/16d5647b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/16d5647b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/16d5647b
Branch: refs/heads/7
Commit: 16d5647bee30345ffa56b5b7d5bebc1021afa3fa
Parents: 574cb36
Author: Matt Post <po...@cs.jhu.edu>
Authored: Fri Aug 19 19:45:12 2016 -0500
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Fri Aug 19 19:45:12 2016 -0500
----------------------------------------------------------------------
.../joshua/decoder/ff/phrase/Distortion.java | 23 +++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/16d5647b/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 072162b..d4b49db 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
@@ -60,14 +60,27 @@ public class Distortion extends StatelessFF {
// int start_point = j - rule.getFrench().length + rule.getArity();
// int jump_size = Math.abs(tailNodes.get(0).j - start_point);
- int start_point = tailNodes.get(rule == Hypothesis.MONO_RULE ? 0 : 1).j;
- int jump_size = Math.abs(j - start_point);
+ if (rule == Hypothesis.MONO_RULE) {
+ 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_point, start_point, jump_size));
- acc.add(denseFeatureIndex, -jump_size);
+ acc.add(denseFeatureIndex, -jump_size);
+ } else {
+ 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_point, start_point, jump_size));
+
+ 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));
-
return null;
}
}