public List<OcelotSegment> getGoalSegments() {
    List<OcelotSegment> segs = new ArrayList<>();

    SimpleSegment.Builder seg1 = new SimpleSegment.Builder().segmentNumber(1);
    seg1.source().text("Sentence 1. Sentence 2.");
    seg1.target().text("");
    segs.add(seg1.build());

    SimpleSegment.Builder seg2 = new SimpleSegment.Builder().segmentNumber(2);
    seg2.source().text("Sentence 3 (no-trans). Sentence 4 (no-trans).");
    seg2.target().text("");
    segs.add(seg2.build());

    SimpleSegment.Builder seg3 = new SimpleSegment.Builder().segmentNumber(3);
    seg3.source().text("Sentence 5.");
    seg3.target().text("");
    segs.add(seg3.build());

    SimpleSegment.Builder seg4 = new SimpleSegment.Builder().segmentNumber(4);
    seg4.source().text("Sentence 6 (no-trans).");
    seg4.target().text("");
    segs.add(seg4.build());

    SimpleSegment.Builder seg5 = new SimpleSegment.Builder().segmentNumber(5);
    seg5.source().text("Sentence 7. Sentence 8. ");
    seg5.target().text("");
    segs.add(seg5.build());

    SimpleSegment.Builder seg6 = new SimpleSegment.Builder().segmentNumber(6);
    seg6.source().text("Sentence with A. Sentence with <cp hex=\"0001\"/>. ");
    seg6.target().text("Sentence with A. Sentence with <cp hex=\"0001\"/>. ");
    segs.add(seg6.build());

    return segs;
  }
示例#2
0
  @Test
  public void exportTaggedTmx() throws Exception {
    SimpleSegment.Builder segBuilder = new SimpleSegment.Builder().segmentNumber(1);
    segBuilder
        .source()
        .code("1", "<mrk>", "<mrk id=\"1\" type=\"its:its\" translate=\"no\"")
        .text("test")
        .code("2", "<mrk>", "<mrk id=\"2\" type=\"its:its\" translate=\"no\"");
    segBuilder
        .target()
        .code("1", "<mrk>", "<mrk id=\"1\" type=\"its:its\" translate=\"no\"")
        .text("test")
        .code("2", "<mrk>", "<mrk id=\"2\" type=\"its:its\" translate=\"no\"");
    setupTmxWriter(segBuilder.build());

    tmxWriter.setOpenFileLangs(new OpenFileEvent("export_tagged_tmx_test", getMockXLIFFDoc()));
    tmxWriter.exportTmx(testFile);
    assertExportedTmxFilesEqual(
        testFile, TestOkapiTmxWriter.class.getResourceAsStream("export_tagged_tmx_test_goal.tmx"));
  }
示例#3
0
  @Test
  public void exportMultipleSegmentsTmx() throws Exception {
    final OcelotSegment seg1 =
        new SimpleSegment.Builder().segmentNumber(1).source("source 1").target("target 1").build();

    SimpleSegment.Builder seg2Builder = new SimpleSegment.Builder().segmentNumber(2);
    seg2Builder
        .source()
        .code("1", "<mrk>", "<mrk id=\"1\" type=\"its:its\" translate=\"no\"")
        .text("test")
        .code("2", "<mrk>", "<mrk id=\"2\" type=\"its:its\" translate=\"no\"");
    seg2Builder
        .target()
        .code("1", "<mrk>", "<mrk id=\"1\" type=\"its:its\" translate=\"no\"")
        .text("test")
        .code("2", "<mrk>", "<mrk id=\"2\" type=\"its:its\" translate=\"no\"");
    final OcelotSegment seg2 = seg2Builder.build();

    mockery.checking(
        new Expectations() {
          {
            allowing(segService).getNumSegments();
            will(returnValue(2));
            allowing(segService).getSegment(0);
            will(returnValue(seg1));
            allowing(segService).getSegment(1);
            will(returnValue(seg2));
          }
        });
    tmxWriter = new OkapiTmxWriter(segService);

    tmxWriter.setOpenFileLangs(
        new OpenFileEvent("export_multiple_segments_tmx_test", getMockXLIFFDoc()));
    tmxWriter.exportTmx(testFile);
    assertExportedTmxFilesEqual(
        testFile,
        TestOkapiTmxWriter.class.getResourceAsStream("export_multiple_segments_tmx_test_goal.tmx"));
  }
  public List<OcelotSegment> getTagGoalSegments() {
    List<OcelotSegment> segs = new ArrayList<>();

    SimpleSegment.Builder seg1 = new SimpleSegment.Builder();
    seg1.source()
        .text("Sentence 1.")
        .code("1", "<mrk1>", "<mrk id=\"1\" type=\"its:its\" translate=\"no\">")
        .text("LQI")
        .code("1", "</mrk1>", "</mrk>")
        .text(" Sentence 2.");
    seg1.target()
        .text("Sentence 1.")
        .code("1", "<mrk2>", "<mrk id=\"1\" type=\"its:its\" translate=\"no\">")
        .text("Prov")
        .code("1", "</mrk2>", "</mrk>")
        .text(" Sentence 2.");
    segs.add(seg1.build());

    SimpleSegment.Builder seg2 = new SimpleSegment.Builder();
    seg2.source().text("Sentence with A. Sentence with <cp hex=\"0001\"/>. ");
    seg2.target().text("Sentence with A. Sentence with <cp hex=\"0001\"/>. ");
    segs.add(seg2.build());

    SimpleSegment.Builder seg3 = new SimpleSegment.Builder();
    seg3.source().text("Ph element ").code("1", "<phph1/>", "<ph id=\"ph1\"/>").text(" #1.");
    seg3.target().text("Ph element ").code("1", "<phph1/>", "<ph id=\"ph1\"/>").text(" #1.");
    segs.add(seg3.build());

    SimpleSegment.Builder seg4 = new SimpleSegment.Builder();
    seg4.source()
        .text("Pc element ")
        .code("1", "<pcpc1>", "<pc id=\"pc1\">")
        .text("Important")
        .code("1", "</pcpc1>", "</pc>")
        .text(" #1.");
    seg4.target()
        .text("Pc element ")
        .code("1", "<pcpc1>", "<pc id=\"pc1\">")
        .text("Important")
        .code("1", "</pcpc1>", "</pc>")
        .text(" #1.");
    segs.add(seg4.build());

    SimpleSegment.Builder seg5 = new SimpleSegment.Builder();
    seg5.source()
        .text("Text in ")
        .code("1", "<scsc1/>", "<sc id=\"sc1\"")
        .text("bold ")
        .code("1", "<pcsc2>", "<sc id=\"sc2\"/>")
        .text("and")
        .code("1", "<ecsc1/>", "<ec startRef=\"sc1\"/>")
        .text(" italics")
        .code("1", "</pcsc2>", "<ec startRef=\"sc2\"/>")
        .text(".");
    seg5.target()
        .text("Text in ")
        .code("1", "<scsc1/>", "<sc id=\"sc1\"/>")
        .text("bold ")
        .code("1", "<pcsc2>", "<sc id=\"sc2\"/>")
        .text("and")
        .code("1", "<ecsc1/>", "<ec startRef=\"sc1\"/>")
        .text(" italics")
        .code("1", "</pcsc2>", "<ec startRef=\"sc2\"/>")
        .text(".");
    segs.add(seg5.build());

    SimpleSegment.Builder seg6 = new SimpleSegment.Builder();
    seg6.source()
        .text("Mrk element ")
        .code("1", "<mrkmrk1>", "<mrk id=\"mrk1\" translate=\"yes\">")
        .text("Important")
        .code("1", "</mrkmrk1>", "</mrk>")
        .text(" #1.");
    seg6.target()
        .text("Mrk element ")
        .code("1", "<mrkmrk1>", "<mrk id=\"mrk1\" translate=\"yes\">")
        .text("Important")
        .code("1", "</mrkmrk1>", "</mrk>")
        .text(" #1.");
    segs.add(seg6.build());

    SimpleSegment.Builder seg7 = new SimpleSegment.Builder();
    seg7.source()
        .text("Sm split element ")
        .code("1", "<smsm1/>", "<sm id=\"sm1\" translate=\"no\"/>")
        .text(" #1.");
    seg7.target()
        .text("Sm split element ")
        .code("1", "<smsm1/>", "<sm id=\"sm1\" translate=\"no\"/>")
        .text(" #1.");
    segs.add(seg7.build());

    SimpleSegment.Builder seg8 = new SimpleSegment.Builder();
    seg8.source()
        .text("Em split element ")
        .code("1", "<emsm1/>", "<em startRef=\"sm1\"/>")
        .text(" #1.");
    seg8.target()
        .text("Em split element ")
        .code("1", "<emsm1/>", "<em startRef=\"sm1\"/>")
        .text(" #1.");
    segs.add(seg8.build());
    return segs;
  }