Search in sources :

Example 1 with TextFilter

use of org.omegat.filters2.text.TextFilter in project omegat by omegat-org.

the class TextFilterTest method testLineLengthLimit.

@Test
public void testLineLengthLimit() throws Exception {
    Map<String, String> options = new TreeMap<String, String>();
    options.put(TextFilter.OPTION_SEGMENT_ON, TextFilter.SEGMENT_EMPTYLINES);
    options.put(TextFilter.OPTION_LINE_LENGTH, "8");
    options.put(TextFilter.OPTION_MAX_LINE_LENGTH, "10");
    TextFilter filter = new TextFilter();
    translate(filter, "test/data/filters/text/file-TextFilter-SMP.txt", options);
    compareBinary(new File("test/data/filters/text/file-TextFilter-SMP-gold.txt"), outFile);
}
Also used : TextFilter(org.omegat.filters2.text.TextFilter) TreeMap(java.util.TreeMap) File(java.io.File) Test(org.junit.Test)

Example 2 with TextFilter

use of org.omegat.filters2.text.TextFilter in project omegat by omegat-org.

the class TextFilterTest method checkFile.

protected void checkFile(String segValue, int count1, int count2) throws Exception {
    Map<String, String> options = new TreeMap<String, String>();
    options.put(TextFilter.OPTION_SEGMENT_ON, segValue);
    TextFilter filter = new TextFilter();
    List<String> entries = parse(filter, "test/data/filters/text/file-TextFilter.txt", options);
    assertEquals(count1, entries.size());
    entries = parse(filter, "test/data/filters/text/file-TextFilter-noemptylines.txt", options);
    assertEquals(count2, entries.size());
}
Also used : TextFilter(org.omegat.filters2.text.TextFilter) TreeMap(java.util.TreeMap)

Example 3 with TextFilter

use of org.omegat.filters2.text.TextFilter in project omegat by omegat-org.

the class TextFilterTest method testTextFilterParsing.

@Test
public void testTextFilterParsing() throws Exception {
    List<String> entries = parse(new TextFilter(), "test/data/filters/text/text1.txt");
    assertEquals("First entry\r\n", entries.get(0));
}
Also used : TextFilter(org.omegat.filters2.text.TextFilter) Test(org.junit.Test)

Example 4 with TextFilter

use of org.omegat.filters2.text.TextFilter in project omegat by omegat-org.

the class TmxComplianceBase method translateAndCheckTextUsingTmx.

protected void translateAndCheckTextUsingTmx(String fileTextIn, String inCharset, String fileTMX, String fileTextOut, String outCharset, String sourceLang, String targetLang, Map<String, TMXEntry> tmxPatch) throws Exception {
    TextFilter f = new TextFilter();
    Map<String, String> c = new TreeMap<String, String>();
    c.put(TextFilter.OPTION_SEGMENT_ON, TextFilter.SEGMENT_BREAKS);
    ProjectProperties props = new TestProjectProperties(sourceLang, targetLang);
    translateUsingTmx(f, c, fileTextIn, inCharset, fileTMX, outCharset, props, tmxPatch);
    compareTexts(new File("test/data/tmx/TMXComplianceKit/" + fileTextOut), outCharset, outFile, outCharset);
}
Also used : TextFilter(org.omegat.filters2.text.TextFilter) TreeMap(java.util.TreeMap) File(java.io.File)

Example 5 with TextFilter

use of org.omegat.filters2.text.TextFilter in project omegat by omegat-org.

the class TextFilterTest method testLoad.

@Test
public void testLoad() throws Exception {
    String f = "test/data/filters/text/file-TextFilter-multiple.txt";
    IProject.FileInfo fi = loadSourceFiles(new TextFilter(), f);
    checkMultiStart(fi, f);
    checkMulti("line1", null, null, "", "line2", null);
    checkMulti("line2", null, null, "line1", "line3", null);
    checkMulti("line3", null, null, "line2", "", null);
    checkMultiEnd();
}
Also used : TextFilter(org.omegat.filters2.text.TextFilter) IProject(org.omegat.core.data.IProject) Test(org.junit.Test)

Aggregations

TextFilter (org.omegat.filters2.text.TextFilter)5 TreeMap (java.util.TreeMap)3 Test (org.junit.Test)3 File (java.io.File)2 IProject (org.omegat.core.data.IProject)1