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:45 UTC
[17/29] incubator-joshua git commit: Moved regression test
decoder/left-state to unit test.
Moved regression test decoder/left-state 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/74e6c004
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/74e6c004
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/74e6c004
Branch: refs/heads/7
Commit: 74e6c0045a1eb64b5f02eca68027c7bb681d99c5
Parents: cb42ce6
Author: Michael A. Hedderich <mi...@users.noreply.github.com>
Authored: Wed Sep 14 15:55:18 2016 +0200
Committer: Michael A. Hedderich <mi...@users.noreply.github.com>
Committed: Wed Sep 14 15:55:18 2016 +0200
----------------------------------------------------------------------
.../joshua/decoder/cky/LeftStateTest.java | 65 +
.../joshua/decoder/cky/NoGrammarTest.java | 1 -
.../resources/decoder/left-state/joshua.config | 9 +-
.../resources/decoder/left-state/output.gold | 1200 +++++++++---------
.../decoder/left-state/output.scores.gold | 600 ---------
src/test/resources/decoder/left-state/test.sh | 33 -
6 files changed, 671 insertions(+), 1237 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/74e6c004/src/test/java/org/apache/joshua/decoder/cky/LeftStateTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/joshua/decoder/cky/LeftStateTest.java b/src/test/java/org/apache/joshua/decoder/cky/LeftStateTest.java
new file mode 100644
index 0000000..fff1550
--- /dev/null
+++ b/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/74e6c004/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
index 296042a..b814d08 100644
--- a/src/test/java/org/apache/joshua/decoder/cky/NoGrammarTest.java
+++ b/src/test/java/org/apache/joshua/decoder/cky/NoGrammarTest.java
@@ -23,7 +23,6 @@ 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;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/74e6c004/src/test/resources/decoder/left-state/joshua.config
----------------------------------------------------------------------
diff --git a/src/test/resources/decoder/left-state/joshua.config b/src/test/resources/decoder/left-state/joshua.config
index dae08c0..75023d2 100644
--- a/src/test/resources/decoder/left-state/joshua.config
+++ b/src/test/resources/decoder/left-state/joshua.config
@@ -1,7 +1,7 @@
-lm = kenlm 5 true false 100 lm.gz
+lm = kenlm 5 true false 100 src/test/resources/decoder/left-state/lm.gz
-tm = thrax pt 12 grammar.gz
-tm = thrax glue -1 glue-grammar
+tm = thrax pt 12 src/test/resources/decoder/left-state/grammar.gz
+tm = thrax glue -1 src/test/resources/decoder/left-state/glue-grammar
mark_oovs=false
@@ -19,6 +19,9 @@ top-n = 300
feature_function = WordPenalty
feature_function = OOVPenalty
+output-format = "%c %s"
+
+
# Model Weights ####
lm_0 1.2373676802179452