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/02 04:09:31 UTC

incubator-joshua git commit: fixed bug in truncation logic

Repository: incubator-joshua
Updated Branches:
  refs/heads/master 3b2a17c0c -> cf5fbb5ac


fixed bug in truncation logic


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

Branch: refs/heads/master
Commit: cf5fbb5acb7b9d02c826e274009a4017588787c9
Parents: 3b2a17c
Author: Matt Post <po...@cs.jhu.edu>
Authored: Sun May 1 22:09:13 2016 -0400
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Sun May 1 22:09:13 2016 -0400

----------------------------------------------------------------------
 src/joshua/decoder/segment_file/Sentence.java |  2 +-
 test/decoder/too-long/output.gold             |  4 +++
 test/decoder/too-long/test.sh                 | 36 ++++++++++++++++++++++
 3 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/cf5fbb5a/src/joshua/decoder/segment_file/Sentence.java
----------------------------------------------------------------------
diff --git a/src/joshua/decoder/segment_file/Sentence.java b/src/joshua/decoder/segment_file/Sentence.java
index 08ecf89..985a9fe 100644
--- a/src/joshua/decoder/segment_file/Sentence.java
+++ b/src/joshua/decoder/segment_file/Sentence.java
@@ -114,7 +114,7 @@ public class Sentence {
     }
     
     // Only trim strings
-    if (joshuaConfiguration.lattice_decoding && ! source.startsWith("((("))
+    if (! (joshuaConfiguration.lattice_decoding && source.startsWith("(((")))
       adjustForLength(joshuaConfiguration.maxlen);
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/cf5fbb5a/test/decoder/too-long/output.gold
----------------------------------------------------------------------
diff --git a/test/decoder/too-long/output.gold b/test/decoder/too-long/output.gold
new file mode 100644
index 0000000..8773765
--- /dev/null
+++ b/test/decoder/too-long/output.gold
@@ -0,0 +1,4 @@
+0 ||| as kingfishers ||| tm_glue_0=2.000 ||| 0.000
+0 ||| dragonflies ||| tm_glue_0=1.000 ||| 0.000
+0 ||| (((as tumbled over rim in roundy wells stones ||| tm_glue_0=8.000 ||| 0.000
+0 |||  |||  ||| 0.000

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/cf5fbb5a/test/decoder/too-long/test.sh
----------------------------------------------------------------------
diff --git a/test/decoder/too-long/test.sh b/test/decoder/too-long/test.sh
new file mode 100755
index 0000000..03b8dbc
--- /dev/null
+++ b/test/decoder/too-long/test.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+set -u
+
+# Ensures that the decoder trims inputs when and only when it should
+
+(
+echo as kingfishers draw fire | joshua -maxlen 2
+echo dragonflies draw flame | joshua -maxlen 1 -lattice-decoding
+echo "(((as tumbled over rim in roundy wells stones ring" | joshua -maxlen 8
+echo "(((like each tucked string tells" | joshua -maxlen 3 -lattice-decoding
+) > output 2> log
+
+diff -u output output.gold > diff
+
+if [ $? -eq 0 ]; then
+    rm -f log output diff
+    exit 0
+else
+    exit 1
+fi