Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 import java.util.List;
 import org.junit.Test;
 import org.junit.Rule;
 public class LexiconStreamedTest {
     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";
     public void testRead() throws Exception {
         ..println("--- READ TEST START ---");
         testRead(is, EnumSet.of(..));
         ..println("--- READ TEST END ---");
     private void testRead(InputStream isEnumSet<LexiconLayerTaglayersToReadthrows Exception {
         Lexicon lx = new LexiconStreamed(islayersToRead);
         FrequenciesLayer freqLayer = lx.getFrequenciesLayer();
         Frequency f1 = freqLayer.getFrequency(0);
         Entry entryOfFreqAnnotation = freqLayer.getEntry(f1);
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("--- WRITE TEST START ---");
         OutputStream os = new FileOutputStream(ofile);
         testReadWrite(is, EnumSet.of(.),
         ..println("--- WRITE TEST END ---");
     private void testReadWrite(InputStream is,
             EnumSet<LexiconLayerTaglayersToReadOutputStream os,
             boolean outputAsXmlFragmentthrows WLFormatException {
         LexiconStreamed lx = new LexiconStreamed(islayersToReadosoutputAsXmlFragment);
         ..println("Before write:\n" + lx);
         ..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(i + "-faked-cooccurence-term-to-be-replaced"));
        ..println("After cooccurences write:\n" + lx);
        // IMPORTANT: Close the LexiconStreamer streams!!!
New to GrepCode? Check out our FAQ X