Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package eu.clarin.weblicht.wlfxb.io;
  
 import java.io.File;
 import java.util.List;
 import org.junit.Test;
 import org.junit.Rule;
 
 public class LexiconStreamedTest {
 
     @Rule
     public TemporaryFolder testFolder = new TemporaryFolder();
 
     private static final String INPUT_FILE_FOR_READ = "/data/streamer/lx-karin.xml";
     private static final String INPUT_FILE_FOR_REWRITE = "/data/streamer/lx-karin-ent_freq.xml";
     private static final String OUTPUT_FILE_ADD_COOCCURRENCES = "output-add_cooc.xml";
 
     @Test
     public void testRead() throws Exception {
         ..println();
         ..println("--- READ TEST START ---");
         testRead(is, EnumSet.of(..));
         ..println("--- READ TEST END ---");
         ..println();
     }
 
     private void testRead(InputStream isEnumSet<LexiconLayerTaglayersToReadthrows Exception {
         Lexicon lx = new LexiconStreamed(islayersToRead);
         ..println(lx.getEntriesLayer());
         FrequenciesLayer freqLayer = lx.getFrequenciesLayer();
         Frequency f1 = freqLayer.getFrequency(0);
         Entry entryOfFreqAnnotation = freqLayer.getEntry(f1);
         ..println(entryOfFreqAnnotation);
         ..println(lx);
     }
 
     @Test
    
This test rewrites tcf from input file to output file adding lemmas and sentences layers. All the layers in input file, including those not used (not requested for read) are rewritten into the output file.
 
     public void testReadWriteAddingSentsLemms() throws Exception {
         ..println();
         ..println("--- WRITE TEST START ---");
         OutputStream os = new FileOutputStream(ofile);
         testReadWrite(is, EnumSet.of(.),
                 osfalse);
         ..println("--- WRITE TEST END ---");
         ..println();
     }
 
 
     private void testReadWrite(InputStream is,
             EnumSet<LexiconLayerTaglayersToReadOutputStream os,
             boolean outputAsXmlFragmentthrows WLFormatException {
 
         LexiconStreamed lx = new LexiconStreamed(islayersToReadosoutputAsXmlFragment);
         ..println();
         ..println("Before write:\n" + lx);
         ..println();
 
 
         ..println();
         ..println("INSPECT XML RESULT IN:\n" + );
 
     }
 
     
 
 
         // add cooccurrences:
         CooccurrencesLayer layer = lx.createCooccurrencesLayer();
         for (int i = 0; i < lx.getEntriesLayer().size(); i++) {
             Entry entry = lx.getEntriesLayer().getEntry(i);
             List<Termterms = new ArrayList<Term>();
             terms.add(layer.createTerm(entry));
             terms.add(layer.createTerm(i + "-faked-cooccurence-term-to-be-replaced"));
             layer.addCooccurrence(.terms);
         }
 
        ..println("After cooccurences write:\n" + lx);
        // IMPORTANT: Close the LexiconStreamer streams!!!
        lx.close();
    }
New to GrepCode? Check out our FAQ X