summaryrefslogtreecommitdiff
path: root/src-test/morfologik/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src-test/morfologik/tools')
-rw-r--r--src-test/morfologik/tools/LauncherTest.java26
-rw-r--r--src-test/morfologik/tools/MorphEncoderTest.java125
-rw-r--r--src-test/morfologik/tools/MorphEncodingToolTest.java110
-rw-r--r--src-test/morfologik/tools/Text2FSA5Test.java37
4 files changed, 0 insertions, 298 deletions
diff --git a/src-test/morfologik/tools/LauncherTest.java b/src-test/morfologik/tools/LauncherTest.java
deleted file mode 100644
index da94df7..0000000
--- a/src-test/morfologik/tools/LauncherTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package morfologik.tools;
-
-import java.util.Map;
-
-import morfologik.tools.Launcher.ToolInfo;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/*
- *
- */
-public class LauncherTest {
- /* */
- @Test
- public void testTools() throws Exception {
- for (Map.Entry<String, ToolInfo> e : Launcher.initTools().entrySet()) {
- try {
- e.getValue().invoke(new String[] {});
- } catch (Throwable t) {
- Assert.fail("Unable to launch " + e.getKey() + ": "
- + t.getMessage());
- }
- }
- }
-}
diff --git a/src-test/morfologik/tools/MorphEncoderTest.java b/src-test/morfologik/tools/MorphEncoderTest.java
deleted file mode 100644
index a9b8f0d..0000000
--- a/src-test/morfologik/tools/MorphEncoderTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package morfologik.tools;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.UnsupportedEncodingException;
-
-import morfologik.tools.MorphEncoder;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static morfologik.tools.MorphEncoder.*;
-
-/*
- *
- */
-public class MorphEncoderTest {
- private MorphEncoder encoder;
-
- @Before
- public void setUp() {
- encoder = new MorphEncoder();
- }
-
- @Test
- public void testCommonPrefix() {
- assertEquals(3, commonPrefix("abc".getBytes(), "abcd".getBytes()));
- assertEquals(0, commonPrefix("abc".getBytes(), "cba".getBytes()));
- }
-
- @Test
- public void testStandardEncode() throws UnsupportedEncodingException {
- assertEquals("abc+Ad+tag",
- asString(encoder.standardEncode(
- "abc".getBytes("UTF-8"),
- "abcd".getBytes("UTF-8"),
- "tag".getBytes("UTF-8")), "UTF-8"));
-
- assertEquals("abc+Dxyz+tag", encoder.standardEncodeUTF8("abc", "xyz", "tag"));
- assertEquals("abc+Bć+tag", encoder.standardEncodeUTF8("abc", "abć", "tag"));
- }
-
- @Test
- public void testSeparatorChange() throws UnsupportedEncodingException {
- assertEquals("abc+Ad+tag",
- asString(encoder.standardEncode(
- "abc".getBytes("UTF-8"),
- "abcd".getBytes("UTF-8"),
- "tag".getBytes("UTF-8")), "UTF-8"));
-
- encoder = new MorphEncoder((byte) '_');
- assertEquals("abc_Ad_tag",
- asString(encoder.standardEncode(
- "abc".getBytes("UTF-8"),
- "abcd".getBytes("UTF-8"),
- "tag".getBytes("UTF-8")), "UTF-8"));
-
- encoder = new MorphEncoder((byte) '\t');
- assertEquals("abc\tAd\ttag",
- asString(encoder.standardEncode(
- "abc".getBytes("UTF-8"),
- "abcd".getBytes("UTF-8"),
- "tag".getBytes("UTF-8")), "UTF-8"));
- }
-
- @Test
- public void testPrefixEncode() throws UnsupportedEncodingException {
- assertEquals("abc+AAd+tag", asString(
- encoder.prefixEncode(
- "abc".getBytes("UTF-8"),
- "abcd".getBytes("UTF-8"),
- "tag".getBytes("UTF-8")), "UTF-8"));
-
- assertEquals("abcd+AB+tag", asString(
- encoder.prefixEncode(
- "abcd".getBytes("UTF-8"),
- "abc".getBytes("UTF-8"),
- "tag".getBytes("UTF-8")), "US-ASCII"));
-
- assertEquals("abc+ADxyz+tag",
- encoder.prefixEncodeUTF8("abc", "xyz", "tag"));
- assertEquals("abc+ABć+tag",
- encoder.prefixEncodeUTF8("abc", "abć", "tag"));
- assertEquals("postmodernizm+AAu+xyz",
- encoder.prefixEncodeUTF8("postmodernizm", "postmodernizmu", "xyz"));
- assertEquals("postmodernizmu+AB+xyz",
- encoder.prefixEncodeUTF8("postmodernizmu", "postmodernizm", "xyz"));
- assertEquals("nieduży+DA+adj",
- encoder.prefixEncodeUTF8("nieduży", "duży", "adj"));
- assertEquals("postmodernizm+ANmodernizm+xyz",
- encoder.prefixEncodeUTF8("postmodernizm", "modernizm", "xyz"));
- }
-
- @Test
- public void testInfixEncode() throws UnsupportedEncodingException {
- assertEquals("abc+AAAd+tag", encoder.infixEncodeUTF8("abc", "abcd", "tag"));
- assertEquals("abcd+AAB+tag", encoder.infixEncodeUTF8("abcd", "abc", "tag"));
- assertEquals("abc+AADxyz+tag", encoder.infixEncodeUTF8("abc", "xyz", "tag"));
- assertEquals("abc+AABć+tag", encoder.infixEncodeUTF8("abc", "abć", "tag"));
- assertEquals("postmodernizm+AAAu+xyz",
- encoder.infixEncodeUTF8("postmodernizm", "postmodernizmu", "xyz"));
- assertEquals("postmodernizmu+AAB+xyz",
- encoder.infixEncodeUTF8("postmodernizmu", "postmodernizm", "xyz"));
- assertEquals("nieduży+ADA+adj",
- encoder.infixEncodeUTF8("nieduży", "duży", "adj"));
-
- // real infix cases
- assertEquals("kcal+ABA+xyz", encoder.infixEncodeUTF8("kcal", "cal", "xyz"));
- assertEquals("aillent+BBCr+xyz", encoder.infixEncodeUTF8("aillent", "aller", "xyz"));
- assertEquals("laquelle+AAHequel+D f s", encoder.infixEncodeUTF8("laquelle", "lequel", "D f s"));
- assertEquals("ccal+ABA+test", encoder.infixEncodeUTF8("ccal", "cal", "test"));
- }
-
- @Test
- public void testUTF8Boundary() throws UnsupportedEncodingException {
- assertEquals("passagère+Eer+tag", encoder.standardEncodeUTF8("passagère", "passager", "tag"));
- assertEquals("passagère+AAEer+tag", encoder.infixEncodeUTF8("passagère", "passager", "tag"));
- assertEquals("passagère+AEer+tag", encoder.prefixEncodeUTF8("passagère", "passager", "tag"));
- }
-
- @Test
- public void testAsString() throws UnsupportedEncodingException {
- assertEquals("passagère", asString("passagère".getBytes("UTF-8"), "UTF-8"));
- }
-}
diff --git a/src-test/morfologik/tools/MorphEncodingToolTest.java b/src-test/morfologik/tools/MorphEncodingToolTest.java
deleted file mode 100644
index c3d2559..0000000
--- a/src-test/morfologik/tools/MorphEncodingToolTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package morfologik.tools;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/*
- *
- */
-public class MorphEncodingToolTest {
-
- @Test
- public void testTool() throws Exception {
- // Create a simple plain text file.
- File input = File.createTempFile("input", "in");
- File output = File.createTempFile("output", "fsa.txt");
- input.deleteOnExit();
- output.deleteOnExit();
-
- // Populate the file with data.
- PrintWriter w = new PrintWriter(new OutputStreamWriter(
- new FileOutputStream(input), "UTF-8"));
- w.println("passagère\tpassager\ttag");
- w.println("nieduży\tduży\ttest");
- w.println("abcd\tabc\txyz");
- w.close();
-
- // suffix
- MorphEncodingTool.main(new String[] {
- "--input", input.getAbsolutePath(),
- "--output", output.getAbsolutePath(),
- "-suf" });
-
- BufferedReader testOutput = new BufferedReader(new InputStreamReader(
- new FileInputStream(output.getAbsolutePath()), "UTF-8"));
- Assert.assertEquals("passagère+Eer+tag", testOutput.readLine());
- Assert.assertEquals("nieduży+Iduży+test", testOutput.readLine());
- Assert.assertEquals("abcd+B+xyz", testOutput.readLine());
-
- testOutput.close();
-
- // prefix
- MorphEncodingTool.main(new String[] {
- "--input", input.getAbsolutePath(),
- "--output", output.getAbsolutePath(),
- "-pre" });
-
- testOutput = new BufferedReader(new InputStreamReader(
- new FileInputStream(output.getAbsolutePath()), "UTF-8"));
- Assert.assertEquals("passagère+AEer+tag", testOutput.readLine());
- Assert.assertEquals("nieduży+DA+test", testOutput.readLine());
- Assert.assertEquals("abcd+AB+xyz", testOutput.readLine());
-
- testOutput.close();
-
- // infix
- MorphEncodingTool.main(new String[] {
- "--input", input.getAbsolutePath(),
- "--output", output.getAbsolutePath(),
- "-inf" });
-
- testOutput = new BufferedReader(new InputStreamReader(
- new FileInputStream(output.getAbsolutePath()), "UTF-8"));
- Assert.assertEquals("passagère+AAEer+tag", testOutput.readLine());
- Assert.assertEquals("nieduży+ADA+test", testOutput.readLine());
- Assert.assertEquals("abcd+AAB+xyz", testOutput.readLine());
-
- testOutput.close();
-
- }
-
- /* */
- @Test
- public void testStemmingFile() throws Exception {
- // Create a simple plain text file.
- File input = File.createTempFile("input", "in");
- File output = File.createTempFile("output", "fsa.txt");
- input.deleteOnExit();
- output.deleteOnExit();
-
- // Populate the file with data.
-
- // stemming only
- PrintWriter w = new PrintWriter(new OutputStreamWriter(
- new FileOutputStream(input), "UTF-8"));
- w.println("passagère\tpassager");
- w.println("nieduży\tduży");
- w.println("abcd\tabc");
- w.close();
-
- MorphEncodingTool.main(new String[] { "--input",
- input.getAbsolutePath(), "--output", output.getAbsolutePath(),
- "-suf" });
-
- BufferedReader testOutput = new BufferedReader(new InputStreamReader(
- new FileInputStream(output.getAbsolutePath()), "UTF-8"));
- Assert.assertEquals("passagère+Eer+", testOutput.readLine());
- Assert.assertEquals("nieduży+Iduży+", testOutput.readLine());
- Assert.assertEquals("abcd+B+", testOutput.readLine());
-
- testOutput.close();
- }
-}
diff --git a/src-test/morfologik/tools/Text2FSA5Test.java b/src-test/morfologik/tools/Text2FSA5Test.java
deleted file mode 100644
index 573c5da..0000000
--- a/src-test/morfologik/tools/Text2FSA5Test.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package morfologik.tools;
-
-import java.io.*;
-
-import morfologik.fsa.*;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/*
- *
- */
-public class Text2FSA5Test {
- @Test
- public void testTool() throws Exception {
- // Create a simple plain text file.
- File input = File.createTempFile("input", "in");
- File output = File.createTempFile("output", "fsa");
- input.deleteOnExit();
- output.deleteOnExit();
-
- // Populate the file with data.
- PrintWriter w = new PrintWriter(new OutputStreamWriter(new FileOutputStream(input), "UTF-8"));
- w.println("b");
- w.println("cab");
- w.println("ab");
- w.close();
-
- FSABuildTool.main(new String [] {
- "--input", input.getAbsolutePath(),
- "--output", output.getAbsolutePath()
- });
-
- FSA5 fsa = FSA.read(new FileInputStream(output));
- Assert.assertEquals(3, new FSAInfo(fsa).finalStatesCount);
- }
-}