Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 
 package eu.clarin.weblicht.wlfxb.lx.test;
 

Author(s):
Yana Panchenko
    @Rule
    public TemporaryFolder testFolder = new TemporaryFolder();
    private static final String INPUT_FILE_WITHOUT_LAYER = "/data/lx-syl/lx-before.xml";
    private static final String INPUT_FILE_WITH_LAYER = "/data/lx-syl/lx-after.xml";
    private static final String EXPECTED_OUTPUT_FILE = "/data/lx-syl/output-expected.xml";
    private static final String OUTPUT_FILE = "output.xml";
    private static final EnumSet<LexiconLayerTaglayersToReadBefore =
            EnumSet.of(.);
    private static final EnumSet<LexiconLayerTaglayersToReadAfter =
            EnumSet.of(..);
    public static final Map<StringStringlemma2Syllab = new HashMap<StringString>();
    static {
        .put("Peter""Pe-ter");
        .put("essen""e-ssen");
        .put("ein""ein");
        .put("Pizza""Pi-zza");
        .put("sie""sie");
        .put("schmecken""schme-cken");
        .put("er""er");
    }
    @Test
    public void testRead() throws Exception {
        SyllabificationsLayer layer = lex.getSyllabificationsLayer();
        Assert.assertEquals(7, layer.size());
        Assert.assertEquals("pe-ter"layer.getSyllabification(0).getString().toLowerCase());
        Assert.assertEquals(lex.getEntriesLayer().getEntry(0), layer.getEntry(layer.getSyllabification(0)));
        Assert.assertEquals(layer.getSyllabification(5), layer.getSyllabification(lex.getEntriesLayer().getEntry(6)));
    }
    @Test
    public void testReadWrite() throws Exception {
        String outfile = .getRoot() + . + ;
        LexiconStreamed lex = open(outfile);
        ..println(lex);
        SyllabificationsLayer syls = lex.createSyllabificationsLayer();
        for (int i = 0; i < lex.getEntriesLayer().size(); i++) {
            Entry lemma = lex.getEntriesLayer().getEntry(i);
            String syl = syllabify(lemma.getString());
            if (syl != null) {
                syls.addSyllabification(syllemma);
            }
        }
        // IMPORTANT close the streams!!!
        lex.close();
        ..println(lex);
        // compare output xml with expected xml
        assertEqualXml(outfile);
    }
    private String syllabify(String tokenString) {
        return .get(tokenString);
    }
New to GrepCode? Check out our FAQ X