Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 
 package eu.clarin.weblicht.wlfxb.lx.test;
 
import static org.junit.Assert.assertEquals;

Author(s):
Yana Panchenko
    @Rule
    public TemporaryFolder testFolder = new TemporaryFolder();
    private static final String INPUT_FILE_WITHOUT_LAYER = "/data/lx-cooc/lx-before.xml";
    private static final String INPUT_FILE_WITH_LAYER = "/data/lx-cooc/lx-after.xml";
    private static final String EXPECTED_OUTPUT_FILE = "/data/lx-cooc/output-expected.xml";
    private static final String OUTPUT_FILE = "output.xml";
            EnumSet.of(.);
            EnumSet.of(..);
    @Test
    public void testRead() throws Exception {
        CooccurrencesLayer layer = lex.getCooccurrencesLayer();
        Assert.assertEquals(2, layer.size());
        assertEquals("essen"layer.getTermsAsStrings(layer.getCooccurrence(0), true)[0]);
        assertEquals("Banana"layer.getTermsAsStrings(layer.getCooccurrence(0), true)[1]);
        assertEquals("Banana"layer.getTermsAsStrings(layer.getCooccurrence(0), false)[0]);
        
        Cooccurrence[] coocs = layer.getCooccurrences(lex.getEntriesLayer().getEntry(0));
        Cooccurrence[] coocsExpected = new Cooccurrence[0];
        Assert.assertArrayEquals(coocsExpectedcoocs);
        
        coocs = layer.getCooccurrences(lex.getEntriesLayer().getEntry(1));
        coocsExpected = layer.getCooccurrences(lex.getEntriesLayer().getEntry(1));
        Assert.assertArrayEquals(coocsExpectedcoocs);
    }
    @Test
    public void testReadWrite() throws Exception {
        String outfile = .getRoot() + . + ;
        ..println(lex);
        // get lemmas layer
        EntriesLayer entries = lex.getEntriesLayer();
        // create relations layer, it's empty at first
        CooccurrencesLayer coocs = lex.createCooccurrencesLayer();
        annotateWithCooccurrences(entriescoocs);
        // IMPORTANT close the streams!!!
        lex.close();
        ..println(lex);
        // compare output xml with expected xml
        assertEqualXml(outfile);
    }
    private void annotateWithCooccurrences(EntriesLayer entriesCooccurrencesLayer coocs) {
        List<Termterms = new ArrayList<Term>();
        terms.add(coocs.createTerm(entries.getEntry(1)));
        terms.add(coocs.createTerm("Banana"));
        coocs.addCooccurrence(.coocs.createSig(null, (float) 2.7), terms);
        terms = new ArrayList<Term>();
        terms.add(coocs.createTerm(entries.getEntry(6)));
        terms.add(coocs.createTerm("Brot"));
        coocs.addCooccurrence(.coocs.createSig(null, (float) 2.0), terms);
    }
New to GrepCode? Check out our FAQ X