Start line:  
End line:  

Snippet Preview

Snippet HTML Code

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

Author(s):
Yana Panchenko
@SuppressWarnings("deprecation")
    @Rule
    public TemporaryFolder testFolder = new TemporaryFolder();
    private static final String INPUT_FILE_WITHOUT_LAYER = "/data/tc-rels/tcf-before.xml";
    private static final String INPUT_FILE_WITH_LAYER = "/data/tc-rels/tcf-after.xml";
    private static final String EXPECTED_OUTPUT_FILE = "/data/tc-rels/output-expected.xml";
    private static final String OUTPUT_FILE = "output.xml";
    private static final EnumSet<TextCorpusLayerTaglayersToReadBeforeRelTagging =
            EnumSet.of(.);
    private static final EnumSet<TextCorpusLayerTaglayersToReadAfterRelTagging =
            EnumSet.of(..);
    public static final Map<StringStringtoken2ann = new HashMap<StringString>();
    static {
        .put("Peter""subj");
        .put("K√§sepizza""obj");
        .put("Sie""subj");
        .put("ihm""obj");
    }
    @Test
    public void testRead() throws Exception {
        RelationsLayer layer = tc.getRelationsLayer();
        Assert.assertEquals(4, layer.size());
        Assert.assertEquals("subj"layer.getRelation(0).getFunction());
        Assert.assertEquals(tc.getTokensLayer().getToken(0), layer.getTokens(layer.getRelation(0))[0]);
    }
    @Test
    public void testReadWrite() throws Exception {
        String outfile = .getRoot() + . + ;
        ..println(tc);
        // create relations layer, it's empty at first
        RelationsLayer rels = tc.createRelationsLayer("verb-arg");
        for (int i = 0; i < tc.getTokensLayer().size(); i++) {
            Token token = tc.getTokensLayer().getToken(i);
            String relFuncTag = tag(token.getString());
            if (relFuncTag != null) {
                // create and add relation tag to the layer
                rels.addRelation(relFuncTagtoken);
            }
        }
        // IMPORTANT close the streams!!!
        tc.close();
        ..println(tc);
        // compare output xml with expected xml
        assertEqualXml(outfile);
    }
    private String tag(String tokenString) {
        return .get(tokenString);
    }
New to GrepCode? Check out our FAQ X