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 18:22:38 UTC

[10/29] incubator-joshua git commit: Moved regression test decoder/empty-test to unit test.

Moved regression test decoder/empty-test to unit test.


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

Branch: refs/heads/7
Commit: 0871742c7b6512260053969af75c1c2a91ae323a
Parents: 74d8006
Author: Michael A. Hedderich <mi...@users.noreply.github.com>
Authored: Wed Sep 14 14:58:56 2016 +0200
Committer: Michael A. Hedderich <mi...@users.noreply.github.com>
Committed: Wed Sep 14 14:58:56 2016 +0200

----------------------------------------------------------------------
 .../joshua/decoder/cky/NoGrammarTest.java       | 43 ++++++++++++++++++++
 .../resources/decoder/empty-test/.gitignore     |  3 --
 src/test/resources/decoder/empty-test/input     |  1 -
 .../resources/decoder/empty-test/output.gold    |  1 -
 src/test/resources/decoder/empty-test/test.sh   | 29 -------------
 5 files changed, 43 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/0871742c/src/test/java/org/apache/joshua/decoder/cky/NoGrammarTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/joshua/decoder/cky/NoGrammarTest.java b/src/test/java/org/apache/joshua/decoder/cky/NoGrammarTest.java
new file mode 100644
index 0000000..847ac86
--- /dev/null
+++ b/src/test/java/org/apache/joshua/decoder/cky/NoGrammarTest.java
@@ -0,0 +1,43 @@
+package org.apache.joshua.decoder.cky;
+
+import static org.apache.joshua.decoder.cky.TestUtil.translate;
+import static org.testng.Assert.assertEquals;
+
+import org.apache.joshua.decoder.Decoder;
+import org.apache.joshua.decoder.JoshuaConfiguration;
+import org.apache.joshua.util.io.KenLmTestUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class NoGrammarTest {
+
+	private static final String INPUT = "those who hurt others hurt themselves";
+	private static final String GOLD = "0 ||| those_OOV who_OOV hurt_OOV others_OOV hurt_OOV themselves_OOV ||| tm_glue_0=6.000 ||| 0.000";
+	
+	private JoshuaConfiguration joshuaConfig = null;
+	private Decoder decoder = null;
+	
+	@BeforeMethod
+	public void setUp() throws Exception {
+		joshuaConfig = new JoshuaConfiguration();
+		joshuaConfig.mark_oovs = true;
+		KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig, ""));
+	}
+
+	@AfterMethod
+	public void tearDown() throws Exception {
+		decoder.cleanUp();
+		decoder = null;
+	}
+	
+	@Test
+	public void givenInput_whenDecodingWithoutGrammar_thenOutputAllOOV() {
+		String output = translate(INPUT, decoder, joshuaConfig);
+		assertEquals(output.trim(), GOLD);
+	}
+	
+	
+	
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/0871742c/src/test/resources/decoder/empty-test/.gitignore
----------------------------------------------------------------------
diff --git a/src/test/resources/decoder/empty-test/.gitignore b/src/test/resources/decoder/empty-test/.gitignore
deleted file mode 100644
index cf5f806..0000000
--- a/src/test/resources/decoder/empty-test/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-diff
-output
-log

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/0871742c/src/test/resources/decoder/empty-test/input
----------------------------------------------------------------------
diff --git a/src/test/resources/decoder/empty-test/input b/src/test/resources/decoder/empty-test/input
deleted file mode 100644
index ed95e87..0000000
--- a/src/test/resources/decoder/empty-test/input
+++ /dev/null
@@ -1 +0,0 @@
-those who hurt others hurt themselves

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/0871742c/src/test/resources/decoder/empty-test/output.gold
----------------------------------------------------------------------
diff --git a/src/test/resources/decoder/empty-test/output.gold b/src/test/resources/decoder/empty-test/output.gold
deleted file mode 100644
index c914a56..0000000
--- a/src/test/resources/decoder/empty-test/output.gold
+++ /dev/null
@@ -1 +0,0 @@
-0 ||| those_OOV who_OOV hurt_OOV others_OOV hurt_OOV themselves_OOV ||| tm_glue_0=6.000 ||| 0.000

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/0871742c/src/test/resources/decoder/empty-test/test.sh
----------------------------------------------------------------------
diff --git a/src/test/resources/decoder/empty-test/test.sh b/src/test/resources/decoder/empty-test/test.sh
deleted file mode 100755
index 452fbc3..0000000
--- a/src/test/resources/decoder/empty-test/test.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/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
-
-cat input | $JOSHUA/bin/joshua-decoder -mark-oovs true > output 2> log
-
-diff -u output output.gold > diff
-
-if [ $? -eq 0 ]; then
-    rm -f log output diff
-    exit 0
-else
-    exit 1
-fi