Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 
 package eu.clarin.weblicht.wlfxb.tc.test;
 
import java.util.*;

Author(s):
Yana Panchenko
    private static final String INPUT_FILE_WITH_LAYER = "/data/tc-matches/tcf-after.xml";
    private static final String EXPECTED_OUTPUT_FILE = "/data/tc-matches/output-expected.xml";
    private static final String OUTPUT_FILE = "/tmp/output.xml";
    private static final EnumSet<TextCorpusLayerTaglayersToReadAfterQuery =
            EnumSet.of(..);
    @Test
    public void testRead() throws Exception {
        MatchesLayer layer = tc.getMatchesLayer();
        Assert.assertEquals(1, layer.size());
        Token token = layer.getTokens(layer.getCorpus(0).getMatchedItems()[0])[0];
        Assert.assertEquals(tc.getTokensLayer().getToken(0), token);
    }
    @Test
    public void testWrite() throws Exception {
        OutputStream os = new FileOutputStream();
        TextCorpusStored tc = new TextCorpusStored("de");
        WLDObjector.write(new MetaData(), tcosfalse);
        os.close();
        ..println(tc);
        // compare output xml with expected xml
    }
        Map<StringStringtoken2StrId = new LinkedHashMap<StringString>();
        token2StrId.put("Peter""5-1023");
        token2StrId.put("aß""5-1024");
        token2StrId.put("eine""5-1025");
        token2StrId.put("Käsepizza""5-1026");
        token2StrId.put(".""5-1027");
        token2StrId.put("Sie""16-116");
        token2StrId.put("schmeckte""16-117");
        token2StrId.put("ihm""16-118");
        TokensLayer tokensLayer = tc.createTokensLayer();
        MatchesLayer matchesLayer = tc.createMatchesLayer("sqp""tb_lemma=\"Peter\" | tb_lemma=\"schmecken\"");
        MatchedCorpus corpus = matchesLayer.addCorpus("wcorp-1""some-pid");
        for (String t : token2StrId.keySet()) {
            Token token = tokensLayer.addToken(t);
            if (t.equals("Peter") || t.equals("schmeckte")) {
                Map<StringStringtargets = new HashMap<StringString>();
                targets.put("tname"token.getID());
                Map<StringStringcats = new HashMap<StringString>();
                cats.put("cname""cval");
                List<TokenrefToks = Arrays.asList(new Token[]{token});
                List<StringrefOrigToks = Arrays.asList(new String[]{token2StrId.get(t)});
                matchesLayer.addItem(corpus,
                        refToks,
                        refOrigToks,
                        targetscats);
            }
        }
    }
New to GrepCode? Check out our FAQ X