Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package eu.clarin.weblicht.wlfxb.io;
  
 import java.util.Map;
 import org.junit.Test;
 import org.junit.Rule;

Author(s):
Yana Panchenko <yana.panchenko@uni-tuebingen.de>
 
 
     @Rule
     public TemporaryFolder testFolder = new TemporaryFolder();
 
     private static final String INPUT_FILE_WITH_LAYER = "/data/streamer/tcf-text_toks_sents_pos_lem.xml";
     private static final String EXPECTED_OUTPUT_FILE = "/data/streamer/tcf-text_toks_sents_pos_changed-lem.xml";
     private static final String OUTPUT_FILE = "output.xml";
     private static final EnumSet<TextCorpusLayerTaglayersToRead =
             EnumSet.of(.);
     private static final EnumSet<TextCorpusLayerTaglayersToReplace =
             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("Sie""sie");
         .put("schmeckte""schmecken");
         .put("ihm""er");
     }
 
 
     @Test
     public void testReadWrite() throws Exception {
         junit.framework.Assert.assertNotNull("can't open input resource"is);
         junit.framework.Assert.assertNotNull("can't open output file"os);
         
         // 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
             if (lemmaString != null) {
                 lemmas.addLemma(lemmaStringtoken);
             }
         }
         // IMPORTANT close the streams!!!
         tc.close();
         ..println(tc);
         // compare output xml with expected xml
         //assertEqualXml(EXPECTED_OUTPUT_FILE, OUTPUT_FILE);
         InputStream expected = this.getClass().getResourceAsStream();
         junit.framework.Assert.assertNotNull("can't open expected output resource"expected);
         InputStream actual = new FileInputStream(.newFile());
         junit.framework.Assert.assertNotNull("can't open actual output resource"actual);
         TestUtils.assertEqualXml(expectedactual);
     }
 
    private String lemmatize(String tokenString) {
        return .get(tokenString);
    }
New to GrepCode? Check out our FAQ X