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:14:01 UTC

[28/30] incubator-joshua git commit: denormalization

denormalization


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

Branch: refs/heads/7_confsystem
Commit: a39c0552b21170c403f8d097db5a9584214ffb08
Parents: a47d727
Author: Matt Post <po...@cs.jhu.edu>
Authored: Sat Sep 17 22:21:53 2016 +0200
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Sat Sep 17 22:21:53 2016 +0200

----------------------------------------------------------------------
 .../joshua/decoder/cky/DenormalizationTest.java | 79 ++++++++++----------
 .../resources/decoder/denormalization/input.txt |  1 -
 .../decoder/denormalization/output.expected     |  1 -
 .../resources/decoder/denormalization/test.sh   | 30 --------
 4 files changed, 38 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/a39c0552/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
index f51844f..d6fbc09 100644
--- 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
@@ -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,37 +18,38 @@ 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 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);
-	}	
+  private static final String INPUT = "� who you lookin' at , mr. ?";
+  private static final String GOLD = "�Who you lookin' at, Mr.?";
+
+  private Decoder decoder = null;
+
+  @BeforeMethod
+  public void setUp() throws Exception {
+    Config config = Decoder.getDefaultFlags()
+        .withValue("top_n", ConfigValueFactory.fromAnyRef(1))
+        .withValue("mark_oovs", ConfigValueFactory.fromAnyRef(false))
+        .withValue("output_format", ConfigValueFactory.fromAnyRef("%S"));
+    decoder = new Decoder(config);
+  }
+
+  @AfterMethod
+  public void tearDown() throws Exception {
+    decoder.cleanUp();
+    decoder = null;
+  }
+
+  @Test
+  public void givenTokenizedInputWithSpecialCharacters_whenDecoding_thenOutputNormalized() {
+    String output = translate(INPUT, decoder);
+    assertEquals(output.trim(), GOLD);
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/a39c0552/joshua-core/src/test/resources/decoder/denormalization/input.txt
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/resources/decoder/denormalization/input.txt b/joshua-core/src/test/resources/decoder/denormalization/input.txt
deleted file mode 100644
index a9dfe65..0000000
--- a/joshua-core/src/test/resources/decoder/denormalization/input.txt
+++ /dev/null
@@ -1 +0,0 @@
-� who you lookin' at , mr. ?

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/a39c0552/joshua-core/src/test/resources/decoder/denormalization/output.expected
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/resources/decoder/denormalization/output.expected b/joshua-core/src/test/resources/decoder/denormalization/output.expected
deleted file mode 100644
index b799fa7..0000000
--- a/joshua-core/src/test/resources/decoder/denormalization/output.expected
+++ /dev/null
@@ -1 +0,0 @@
-�Who you lookin' at, Mr.?

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/a39c0552/joshua-core/src/test/resources/decoder/denormalization/test.sh
----------------------------------------------------------------------
diff --git a/joshua-core/src/test/resources/decoder/denormalization/test.sh b/joshua-core/src/test/resources/decoder/denormalization/test.sh
deleted file mode 100755
index 5043684..0000000
--- a/joshua-core/src/test/resources/decoder/denormalization/test.sh
+++ /dev/null
@@ -1,30 +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.txt | $JOSHUA/bin/joshua-decoder -output-format "%S" -mark-oovs false -top-n 1 > output 2> log
-
-# Compare
-diff -u output output.expected > diff
-
-if [ $? -eq 0 ]; then
-	rm -f output log diff
-	exit 0
-else
-	exit 1
-fi