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/15 11:17:39 UTC

[7/9] incubator-joshua git commit: moved new unit tests (former regression tests) to correct location in joshua 7 (joshua-core/src)

moved new unit tests (former regression tests) to correct location in joshua 7 (joshua-core/src)


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

Branch: refs/heads/7
Commit: ee7398f7d0c921cf1aaf7937a370a41d31431033
Parents: 732997b
Author: Hieber, Felix <fh...@amazon.de>
Authored: Wed Sep 14 23:19:00 2016 +0200
Committer: Hieber, Felix <fh...@amazon.de>
Committed: Wed Sep 14 23:19:00 2016 +0200

----------------------------------------------------------------------
 .../joshua/decoder/cky/BnEnDecodingTest.java    | 121 +++
 .../joshua/decoder/cky/ConstrainedTest.java     |  65 ++
 .../joshua/decoder/cky/DenormalizationTest.java |  58 ++
 .../joshua/decoder/cky/DoNotCrashTest.java      |  62 ++
 .../joshua/decoder/cky/LeftStateTest.java       |  65 ++
 .../joshua/decoder/cky/LowercaseTest.java       | 115 +++
 .../org/apache/joshua/decoder/cky/NAryTest.java |  64 ++
 .../joshua/decoder/cky/NoGrammarTest.java       |  56 ++
 .../org/apache/joshua/decoder/cky/TestUtil.java |  87 ++
 .../bn-en/hiero/output-berkeleylm.gold          | 943 +++++++++++++++++++
 .../src/test/resources/bn-en/samt/output.gold   | 862 +++++++++++++++++
 .../resources/decoder/lowercaser/joshua.config  | 140 +++
 .../decoder/moses-compat/NEEDS_UPDATING         |   1 +
 .../test/resources/phrase_decoder/config.packed |  29 +
 .../phrase_decoder/rules.packed/config          |   2 +
 .../phrase_decoder/rules.packed/encoding        | Bin 0 -> 87 bytes
 .../rules.packed/slice_00000.features           | Bin 0 -> 4128858 bytes
 .../rules.packed/slice_00000.source             | Bin 0 -> 1982228 bytes
 .../rules.packed/slice_00000.target             | Bin 0 -> 1463856 bytes
 .../rules.packed/slice_00000.target.lookup      | Bin 0 -> 28 bytes
 .../phrase_decoder/rules.packed/vocabulary      | Bin 0 -> 169225 bytes
 .../joshua/decoder/cky/BnEnDecodingTest.java    | 121 ---
 .../joshua/decoder/cky/ConstrainedTest.java     |  65 --
 .../joshua/decoder/cky/DenormalizationTest.java |  58 --
 .../joshua/decoder/cky/DoNotCrashTest.java      |  62 --
 .../joshua/decoder/cky/LeftStateTest.java       |  65 --
 .../joshua/decoder/cky/LowercaseTest.java       | 115 ---
 .../org/apache/joshua/decoder/cky/NAryTest.java |  64 --
 .../joshua/decoder/cky/NoGrammarTest.java       |  56 --
 .../org/apache/joshua/decoder/cky/TestUtil.java |  87 --
 .../bn-en/hiero/output-berkeleylm.gold          | 943 -------------------
 src/test/resources/bn-en/samt/output.gold       | 862 -----------------
 .../resources/decoder/lowercaser/joshua.config  | 140 ---
 .../decoder/moses-compat/NEEDS_UPDATING         |   1 -
 src/test/resources/phrase_decoder/config.packed |  29 -
 .../phrase_decoder/rules.packed/config          |   2 -
 .../phrase_decoder/rules.packed/encoding        | Bin 87 -> 0 bytes
 .../rules.packed/slice_00000.features           | Bin 4128858 -> 0 bytes
 .../rules.packed/slice_00000.source             | Bin 1982228 -> 0 bytes
 .../rules.packed/slice_00000.target             | Bin 1463856 -> 0 bytes
 .../rules.packed/slice_00000.target.lookup      | Bin 28 -> 0 bytes
 .../phrase_decoder/rules.packed/vocabulary      | Bin 169225 -> 0 bytes
 42 files changed, 2670 insertions(+), 2670 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/ee7398f7/joshua-core/src/test/java/org/apache/joshua/decoder/cky/BnEnDecodingTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/BnEnDecodingTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/BnEnDecodingTest.java
new file mode 100644
index 0000000..82faa58
--- /dev/null
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/BnEnDecodingTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+package org.apache.joshua.decoder.cky;
+
+import static org.apache.joshua.decoder.cky.TestUtil.decodeList;
+import static org.apache.joshua.decoder.cky.TestUtil.loadStringsFromFile;
+import static org.testng.Assert.assertEquals;
+
+import java.util.List;
+
+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.Test;
+
+public class BnEnDecodingTest {
+
+	private JoshuaConfiguration joshuaConfig;
+	private Decoder decoder;
+
+	@AfterMethod
+	public void tearDown() throws Exception {
+		if(decoder != null) {
+			decoder.cleanUp();
+			decoder = null;
+		}
+	}
+
+	@Test
+	public void givenBnEnInput_whenPhraseDecoding_thenScoreAndTranslationCorrect() throws Exception {
+		// Given
+		List<String> inputStrings = loadStringsFromFile("src/test/resources/bn-en/hiero/input.bn");
+
+		// When
+		configureDecoder("src/test/resources/bn-en/hiero/joshua.config");
+		List<String> decodedStrings = decodeList(inputStrings, decoder, joshuaConfig);
+
+		// Then
+		List<String> goldStrings = loadStringsFromFile("src/test/resources/bn-en/hiero/output.gold");
+		assertEquals(decodedStrings, goldStrings);
+	}
+
+	@Test
+	public void givenBnEnInput_whenPhraseDecodingWithBerkeleyLM_thenScoreAndTranslationCorrect() throws Exception {
+		// Given
+		List<String> inputStrings = loadStringsFromFile("src/test/resources/bn-en/hiero/input.bn");
+
+		// When
+		configureDecoder("src/test/resources/bn-en/hiero/joshua-berkeleylm.config");
+		List<String> decodedStrings = decodeList(inputStrings, decoder, joshuaConfig);
+
+		// Then
+		List<String> goldStrings = loadStringsFromFile("src/test/resources/bn-en/hiero/output-berkeleylm.gold");
+		assertEquals(decodedStrings, goldStrings);
+	}
+
+	@Test
+	public void givenBnEnInput_whenPhraseDecodingWithClassLM_thenScoreAndTranslationCorrect() throws Exception {
+		// Given
+		List<String> inputStrings = loadStringsFromFile("src/test/resources/bn-en/hiero/input.bn");
+
+		// When
+		configureDecoder("src/test/resources/bn-en/hiero/joshua-classlm.config");
+		List<String> decodedStrings = decodeList(inputStrings, decoder, joshuaConfig);
+
+		// Then
+		List<String> goldStrings = loadStringsFromFile("src/test/resources/bn-en/hiero/output-classlm.gold");
+		assertEquals(decodedStrings, goldStrings);
+	}
+	
+	@Test
+	public void givenBnEnInput_whenPhraseDecodingWithPackedGrammar_thenScoreAndTranslationCorrect() throws Exception {
+		// Given
+		List<String> inputStrings = loadStringsFromFile("src/test/resources/bn-en/packed/input.bn");
+
+		// When
+		configureDecoder("src/test/resources/bn-en/packed/joshua.config");
+		List<String> decodedStrings = decodeList(inputStrings, decoder, joshuaConfig);
+
+		// Then
+		List<String> goldStrings = loadStringsFromFile("src/test/resources/bn-en/packed/output.gold");
+		assertEquals(decodedStrings, goldStrings);
+	}
+	
+	@Test
+	public void givenBnEnInput_whenPhraseDecodingWithSAMT_thenScoreAndTranslationCorrect() throws Exception {
+		// Given
+		List<String> inputStrings = loadStringsFromFile("src/test/resources/bn-en/samt/input.bn");
+
+		// When
+		configureDecoder("src/test/resources/bn-en/samt/joshua.config");
+		List<String> decodedStrings = decodeList(inputStrings, decoder, joshuaConfig);
+
+		// Then
+		List<String> goldStrings = loadStringsFromFile("src/test/resources/bn-en/samt/output.gold");
+		assertEquals(decodedStrings, goldStrings);
+	}
+	
+	public void configureDecoder(String pathToConfig) throws Exception {
+		joshuaConfig = new JoshuaConfiguration();
+		joshuaConfig.readConfigFile(pathToConfig);
+		KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig));
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/ee7398f7/joshua-core/src/test/java/org/apache/joshua/decoder/cky/ConstrainedTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/ConstrainedTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/ConstrainedTest.java
new file mode 100644
index 0000000..c8d2304
--- /dev/null
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/ConstrainedTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+package org.apache.joshua.decoder.cky;
+
+import static org.apache.joshua.decoder.cky.TestUtil.decodeList;
+import static org.apache.joshua.decoder.cky.TestUtil.loadStringsFromFile;
+import static org.testng.Assert.assertEquals;
+
+import java.util.List;
+
+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.Test;
+
+public class ConstrainedTest {
+
+	private JoshuaConfiguration joshuaConfig;
+	private Decoder decoder;
+
+	@AfterMethod
+	public void tearDown() throws Exception {
+		if(decoder != null) {
+			decoder.cleanUp();
+			decoder = null;
+		}
+	}
+
+	@Test
+	public void givenInput_whenConstrainedDecoding_thenScoreAndTranslationCorrect() throws Exception {
+		// Given
+		List<String> inputStrings = loadStringsFromFile("src/test/resources/decoder/constrained/input.bn");
+
+		// When
+		configureDecoder("src/test/resources/decoder/constrained/joshua.config");
+		List<String> decodedStrings = decodeList(inputStrings, decoder, joshuaConfig);
+
+		// Then
+		List<String> goldStrings = loadStringsFromFile("src/test/resources/decoder/constrained/output.gold");
+		assertEquals(decodedStrings, goldStrings);
+	}
+	
+	public void configureDecoder(String pathToConfig) throws Exception {
+		joshuaConfig = new JoshuaConfiguration();
+		joshuaConfig.readConfigFile(pathToConfig);
+		KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig));
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/ee7398f7/joshua-core/src/test/java/org/apache/joshua/decoder/cky/DenormalizationTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/DenormalizationTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/DenormalizationTest.java
new file mode 100644
index 0000000..f51844f
--- /dev/null
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/DenormalizationTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+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.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class DenormalizationTest {
+
+	private static final String INPUT = "� who you lookin' at , mr. ?";
+	private static final String GOLD = "�Who you lookin' at, Mr.?";
+	
+	private JoshuaConfiguration joshuaConfig = null;
+	private Decoder decoder = null;
+	
+	@BeforeMethod
+	public void setUp() throws Exception {
+		joshuaConfig = new JoshuaConfiguration();
+		joshuaConfig.outputFormat = "%S";
+		joshuaConfig.mark_oovs = false;
+		joshuaConfig.topN = 1;
+		decoder = new Decoder(joshuaConfig);
+	}
+
+	@AfterMethod
+	public void tearDown() throws Exception {
+		decoder.cleanUp();
+		decoder = null;
+	}
+	
+	@Test
+	public void givenTokenizedInputWithSpecialCharacters_whenDecoding_thenOutputNormalized() {
+		String output = translate(INPUT, decoder, joshuaConfig);
+		assertEquals(output.trim(), GOLD);
+	}	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/ee7398f7/joshua-core/src/test/java/org/apache/joshua/decoder/cky/DoNotCrashTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/DoNotCrashTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/DoNotCrashTest.java
new file mode 100644
index 0000000..4623040
--- /dev/null
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/DoNotCrashTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+package org.apache.joshua.decoder.cky;
+
+import static org.apache.joshua.decoder.cky.TestUtil.decodeList;
+import static org.apache.joshua.decoder.cky.TestUtil.loadStringsFromFile;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.joshua.decoder.Decoder;
+import org.apache.joshua.decoder.JoshuaConfiguration;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class DoNotCrashTest {
+
+	private JoshuaConfiguration joshuaConfig = null;
+	private Decoder decoder = null;
+
+	@BeforeMethod
+	public void setUp() throws Exception {
+		joshuaConfig = new JoshuaConfiguration();
+		decoder = new Decoder(joshuaConfig);
+	}
+
+	@AfterMethod
+	public void tearDown() throws Exception {
+		decoder.cleanUp();
+		decoder = null;
+	}
+
+	@Test
+	public void givenProblematicInput_whenDecoding_thenNoCrash() throws IOException {
+		// Given
+		List<String> inputStrings = loadStringsFromFile("src/test/resources/decoder/dont-crash/input");
+		
+		// When
+		decodeList(inputStrings, decoder, joshuaConfig);
+		
+		// Then
+		// Did not crash
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/ee7398f7/joshua-core/src/test/java/org/apache/joshua/decoder/cky/LeftStateTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/LeftStateTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/LeftStateTest.java
new file mode 100644
index 0000000..602808c
--- /dev/null
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/LeftStateTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+package org.apache.joshua.decoder.cky;
+
+import static org.apache.joshua.decoder.cky.TestUtil.decodeList;
+import static org.apache.joshua.decoder.cky.TestUtil.loadStringsFromFile;
+import static org.testng.Assert.assertEquals;
+
+import java.util.List;
+
+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.Test;
+
+public class LeftStateTest {
+
+	private JoshuaConfiguration joshuaConfig;
+	private Decoder decoder;
+
+	@AfterMethod
+	public void tearDown() throws Exception {
+		if(decoder != null) {
+			decoder.cleanUp();
+			decoder = null;
+		}
+	}
+
+	@Test
+	public void givenInput_whenLeftStateDecoding_thenScoreAndTranslationCorrect() throws Exception {
+		// Given
+		List<String> inputStrings = loadStringsFromFile("src/test/resources/decoder/left-state/input.bn");
+
+		// When
+		configureDecoder("src/test/resources/decoder/left-state/joshua.config");
+		List<String> decodedStrings = decodeList(inputStrings, decoder, joshuaConfig);
+
+		// Then
+		List<String> goldStrings = loadStringsFromFile("src/test/resources/decoder/left-state/output.gold");
+		assertEquals(decodedStrings, goldStrings);
+	}
+	
+	public void configureDecoder(String pathToConfig) throws Exception {
+		joshuaConfig = new JoshuaConfiguration();
+		joshuaConfig.readConfigFile(pathToConfig);
+		KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig));
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/ee7398f7/joshua-core/src/test/java/org/apache/joshua/decoder/cky/LowercaseTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/LowercaseTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/LowercaseTest.java
new file mode 100644
index 0000000..2d8cb49
--- /dev/null
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/LowercaseTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+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.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+public class LowercaseTest {
+
+  private static final String INPUT_ALL_UPPERCASED = "ELLA";
+  private static final String INPUT_CAPITALIZED = "Ella";
+
+  private static final String GOLD_UNTRANSLATED_ALL_UPPERCASED = "ELLA";
+  private static final String GOLD_LOWERCASED = "she";
+  private static final String GOLD_CAPITALIZED = "She";
+  private static final String GOLD_ALL_UPPERCASED = "SHE";
+  
+  private static final String JOSHUA_CONFIG_PATH = "src/test/resources/decoder/lowercaser/joshua.config";
+
+  private JoshuaConfiguration joshuaConfig;
+  private Decoder decoder;
+
+  /**
+   * No match in phrase table (only contains ella), therefore passed through
+   * untranslated.
+   * @throws Exception 
+   */
+  @Test
+  public void givenAllUppercasedInput_whenNotLowercasing_thenLowercasedRuleNotFound() throws Exception {
+    setUp(false, false, false);
+    String output = translate(INPUT_ALL_UPPERCASED, decoder, joshuaConfig);
+    assertEquals(output.trim(), GOLD_UNTRANSLATED_ALL_UPPERCASED);
+  }
+  
+  /**
+   * Match in phrase table (only contains ella), therefore translated.
+   * @throws Exception
+   */
+  @Test
+  public void givenAllUppercasedInput_whenLowercasing_thenLowercasedRuleFound() throws Exception {
+    setUp(true, false, false);
+    String output = translate(INPUT_ALL_UPPERCASED, decoder, joshuaConfig);
+    assertEquals(output.trim(), GOLD_LOWERCASED);
+  }
+  
+  /**
+   * Matches phrase table, not capitalized because projected from first word of sentence
+   * @throws Exception
+   */
+  @Test
+  public void givenCapitalizedInput_whenLowercasingAndProjecting_thenLowercased() throws Exception {
+    setUp(true, true, false);
+    String output = translate(INPUT_CAPITALIZED, decoder, joshuaConfig);
+    assertEquals(output.trim(), GOLD_LOWERCASED);
+  }
+  
+  /**
+   * Matches phrase table, capitalized because of output-format
+   * @throws Exception
+   */
+  @Test
+  public void givenCapitalizedInput_whenLowercasingAndOutputFormatCapitalization_thenCapitalized() throws Exception {
+    setUp(true, true, true);
+    String output = translate(INPUT_CAPITALIZED, decoder, joshuaConfig);
+    assertEquals(output.trim(), GOLD_CAPITALIZED);
+  }
+  
+  /**
+   * Matches phrase table, capitalized because of output-format
+   * @throws Exception
+   */
+  @Test
+  public void givenAllUppercasedInput_whenLowercasingAndProjecting_thenAllUppercased() throws Exception {
+    setUp(true, true, false);
+    String output = translate(INPUT_ALL_UPPERCASED, decoder, joshuaConfig);
+    assertEquals(output.trim(), GOLD_ALL_UPPERCASED);
+  }
+
+  public void setUp(boolean lowercase, boolean projectCase, boolean capitalize) throws Exception {
+    joshuaConfig = new JoshuaConfiguration();
+    joshuaConfig.readConfigFile(JOSHUA_CONFIG_PATH);
+    joshuaConfig.lowercase = lowercase;
+    joshuaConfig.project_case = projectCase;
+    joshuaConfig.outputFormat = capitalize ? "%S" : "%s";
+    decoder = new Decoder(joshuaConfig);
+  }
+  
+  @AfterMethod
+  public void tearDown() throws Exception {
+    decoder.cleanUp();
+    decoder = null;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/ee7398f7/joshua-core/src/test/java/org/apache/joshua/decoder/cky/NAryTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/NAryTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/NAryTest.java
new file mode 100644
index 0000000..5440407
--- /dev/null
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/NAryTest.java
@@ -0,0 +1,64 @@
+package org.apache.joshua.decoder.cky;
+
+import static org.apache.joshua.decoder.cky.TestUtil.decodeList;
+import static org.apache.joshua.decoder.cky.TestUtil.loadStringsFromFile;
+import static org.testng.Assert.assertEquals;
+
+/*
+ * 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.
+ */
+import java.util.List;
+
+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.Test;
+
+public class NAryTest {
+  private JoshuaConfiguration joshuaConfig;
+  private Decoder decoder;
+
+  @AfterMethod
+  public void tearDown() throws Exception {
+    if (decoder != null) {
+      decoder.cleanUp();
+      decoder = null;
+    }
+  }
+
+  @Test
+  public void givenInput_whenNAryDecoding_thenScoreAndTranslationCorrect() throws Exception {
+    // Given
+    List<String> inputStrings = loadStringsFromFile("src/test/resources/decoder/n-ary/input.txt");
+
+    // When
+    configureDecoder("src/test/resources/decoder/n-ary/joshua.config");
+    List<String> decodedStrings = decodeList(inputStrings, decoder, joshuaConfig);
+
+    // Then
+    List<String> goldStrings = loadStringsFromFile("src/test/resources/decoder/n-ary/output.gold");
+    assertEquals(decodedStrings, goldStrings);
+  }
+
+  public void configureDecoder(String pathToConfig) throws Exception {
+    joshuaConfig = new JoshuaConfiguration();
+    joshuaConfig.readConfigFile(pathToConfig);
+    KenLmTestUtil.Guard(() -> decoder = new Decoder(joshuaConfig));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/ee7398f7/joshua-core/src/test/java/org/apache/joshua/decoder/cky/NoGrammarTest.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/NoGrammarTest.java b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/NoGrammarTest.java
new file mode 100644
index 0000000..398fb79
--- /dev/null
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/NoGrammarTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+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.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;
+		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/ee7398f7/joshua-core/src/test/java/org/apache/joshua/decoder/cky/TestUtil.java
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/java/org/apache/joshua/decoder/cky/TestUtil.java b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/TestUtil.java
new file mode 100644
index 0000000..35800c6
--- /dev/null
+++ b/joshua-core/src/test/java/org/apache/joshua/decoder/cky/TestUtil.java
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+package org.apache.joshua.decoder.cky;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.joshua.decoder.Decoder;
+import org.apache.joshua.decoder.JoshuaConfiguration;
+import org.apache.joshua.decoder.segment_file.Sentence;
+
+public class TestUtil {
+
+	public static final String N_BEST_SEPARATOR = "\n";
+
+	/**
+	 * Loads a text file and returns a list containing one string per line
+	 * in the file.
+	 * @param pathToFile
+	 * @return
+	 * @throws IOException
+	 */
+	public static List<String> loadStringsFromFile(String pathToFile) throws IOException {
+		List<String> inputLines = Files.lines(Paths.get(pathToFile)).collect(Collectors.toList());
+		return inputLines;
+	}
+
+	/**
+	 * 
+	 * @param inputStrings
+	 *            A list of strings that should be decoded,
+	 * @param decoder
+	 *            An initialized decoder,
+	 * @param joshuaConfig
+	 *            The JoshuaConfiguration corresponding to the decoder.
+	 * @return A list of decoded strings. If the decoder produces a n-best list
+	 *         (separated by N_BEST_SEPARATOR), then each translation of the
+	 *         n-best list has its own entry in the returned list.
+	 */
+	public static List<String> decodeList(List<String> inputStrings, Decoder decoder,
+			JoshuaConfiguration joshuaConfig) {
+		final List<String> decodedStrings = new ArrayList<>();
+
+		for (String inputString : inputStrings) {
+			final Sentence sentence = new Sentence(inputString, 0, joshuaConfig);
+			final String[] nBestList = decoder.decode(sentence).toString().split(N_BEST_SEPARATOR);
+			decodedStrings.addAll(Arrays.asList(nBestList));
+		}
+
+		return decodedStrings;
+	}
+	
+	/**
+	 * Translates the given input string and returns the translation
+	 * converted into a string.
+	 * @param input
+	 * @param decoder
+	 * @param joshuaConfig
+	 * @return
+	 */
+	public static String translate(String input, Decoder decoder, JoshuaConfiguration joshuaConfig) {
+	    final Sentence sentence = new Sentence(input, 0, joshuaConfig);
+	    return decoder.decode(sentence).toString();
+	}
+
+}