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/18 00:13:58 UTC

[25/30] incubator-joshua git commit: nogrammar / empty test

nogrammar / empty 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/7bbae72c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/7bbae72c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/7bbae72c

Branch: refs/heads/7_confsystem
Commit: 7bbae72c46149441164689fb12a3084c2b40ab35
Parents: a466773
Author: Matt Post <po...@cs.jhu.edu>
Authored: Sat Sep 17 22:09:20 2016 +0200
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Sat Sep 17 22:09:20 2016 +0200

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


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/7bbae72c/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
index cae9c4d..4c52083 100644
--- 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
@@ -1,20 +1,16 @@
 /*
- * 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
+ * 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
+ * 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.
+ * 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;
 
@@ -22,35 +18,36 @@ 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;
 
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigValueFactory;
+
 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 ||| glue_0=-6.000000 ||| 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);
-	}	
+  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 ||| glue_0=-6.000000 ||| 0.000";
+
+  private Decoder decoder = null;
+
+  @BeforeMethod
+  public void setUp() throws Exception {
+    Config config = Decoder.getDefaultFlags()
+        .withValue("mark_oovs",  ConfigValueFactory.fromAnyRef(true));
+    decoder = new Decoder(config);
+  }
+
+  @AfterMethod
+  public void tearDown() throws Exception {
+    decoder.cleanUp();
+    decoder = null;
+  }
+
+  @Test
+  public void givenInput_whenDecodingWithoutGrammar_thenOutputAllOOV() {
+    String output = translate(INPUT, decoder);
+    assertEquals(output.trim(), GOLD);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/7bbae72c/joshua-core/src/test/resources/decoder/empty-test/.gitignore
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/resources/decoder/empty-test/.gitignore b/joshua-core/src/test/resources/decoder/empty-test/.gitignore
deleted file mode 100644
index cf5f806..0000000
--- a/joshua-core/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/7bbae72c/joshua-core/src/test/resources/decoder/empty-test/input
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/resources/decoder/empty-test/input b/joshua-core/src/test/resources/decoder/empty-test/input
deleted file mode 100644
index ed95e87..0000000
--- a/joshua-core/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/7bbae72c/joshua-core/src/test/resources/decoder/empty-test/output.gold
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/resources/decoder/empty-test/output.gold b/joshua-core/src/test/resources/decoder/empty-test/output.gold
deleted file mode 100644
index c914a56..0000000
--- a/joshua-core/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/7bbae72c/joshua-core/src/test/resources/decoder/empty-test/test.sh
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/resources/decoder/empty-test/test.sh b/joshua-core/src/test/resources/decoder/empty-test/test.sh
deleted file mode 100755
index 452fbc3..0000000
--- a/joshua-core/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