Start line:  
End line:  

Snippet Preview

Snippet HTML Code

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

Author(s):
Yana Panchenko
    private static final String INPUT_FILE_WITHOUT_LAYER = "/data/tc-lemmas/tcf-before.xml";
    private static final String INPUT_FILE_WITH_LAYER = "/data/tc-lemmas/tcf-after.xml";
    private static final String EXPECTED_OUTPUT_FILE = "/data/tc-lemmas/output-expected.xml";
    private static final String OUTPUT_FILE = "/tmp/output.xml";
    private static final EnumSet<TextCorpusLayerTaglayersToReadBeforeLemmatization =
            EnumSet.of(.);
    private static final EnumSet<TextCorpusLayerTaglayersToReadAfterLemmatization =
            EnumSet.of(..);
    public static final Map<StringStringtoken2Lemma = new HashMap<StringString>();
    static {
        .put("Peter""Peter");
        .put("aß""essen");
        .put("eine""ein");
        .put("Käsepizza""Käsepizza");
        .put("."".");
        .put("Sie""sie");
        .put("schmeckte""schmecken");
        .put("ihm""er");
    }
    @Test
    public void testRead() throws Exception {
        LemmasLayer layer = tc.getLemmasLayer();
        Assert.assertEquals(9, layer.size());
        Assert.assertEquals("Peter"layer.getLemma(0).getString());
        Assert.assertEquals(tc.getTokensLayer().getToken(0), layer.getTokens(layer.getLemma(0))[0]);
    }
    @Test
    public void testReadWrite() throws Exception {
        ..println(tc);
        // create lemmas layer, empty at first
        LemmasLayer lemmas = tc.createLemmasLayer();
        for (int i = 0; i < tc.getTokensLayer().size(); i++) {
            Token token = tc.getTokensLayer().getToken(i);
            String lemmaString = lemmatize(token.getString());
            // create and add lemma to the lemmas layer
            lemmas.addLemma(lemmaStringtoken);
        }
        // IMPORTANT close the streams!!!
        tc.close();
        ..println(tc);
        // compare output xml with expected xml
    }
    private String lemmatize(String tokenString) {
        return .get(tokenString);
    }
New to GrepCode? Check out our FAQ X