Start line:  
End line:  

Snippet Preview

Snippet HTML Code

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

Author(s):
Yana Panchenko
    @Rule
    public TemporaryFolder testFolder = new TemporaryFolder();
    private static final String INPUT_FILE_WITHOUT_LAYER = "/data/tc-wsplit/tcf-before.xml";
    private static final String INPUT_FILE_WITH_LAYER = "/data/tc-wsplit/tcf-after.xml";
    private static final String EXPECTED_OUTPUT_FILE = "/data/tc-wsplit/output-expected.xml";
    private static final String OUTPUT_FILE = "output.xml";
    private static final EnumSet<TextCorpusLayerTaglayersToReadBeforeSplitting =
            EnumSet.of(.);
    private static final EnumSet<TextCorpusLayerTaglayersToReadAfterSplitting =
    public static final Map<Stringint[]> token2split = new HashMap<Stringint[]>();
    static {
        .put("K√§sepizza"new int[]{2, 4, 6});
        .put("schmeckte"new int[]{5});
    }
    @Test
    public void testRead() throws Exception {
        WordSplittingLayer layer = tc.getWordSplittingLayer();
        Assert.assertEquals(2, layer.size());
        Assert.assertEquals("syllables"layer.getType());
        Assert.assertEquals(tc.getTokensLayer().getToken(3), layer.getToken(layer.getSplit(0)));
    }
    @Test
    public void testReadWrite() throws Exception {
        String outfile = .getRoot() + . + ;
        ..println(tc);
        // create word splittings layer, it's empty at first
        WordSplittingLayer splitsLayer = tc.createWordSplittingLayer("syllables");
        for (int i = 0; i < tc.getTokensLayer().size(); i++) {
            Token token = tc.getTokensLayer().getToken(i);
            int[] split = split(token.getString());
            if (split != null) {
                // create and add split to the layer
                splitsLayer.addSplit(tokensplit);
            }
        }
        // IMPORTANT close the streams!!!
        tc.close();
        ..println(tc);
        // compare output xml with expected xml
        assertEqualXml(outfile);
    }
    private int[] split(String tokenString) {
        return .get(tokenString);
    }
New to GrepCode? Check out our FAQ X