/** * Executes the packing. * * @throws IOException */ public void pack() throws IOException { logger.info("Beginning exploration pass."); LineReader grammar_reader = null; LineReader alignment_reader = null; // Explore pass. Learn vocabulary and feature value histograms. logger.info("Exploring: " + grammar); grammar_reader = new LineReader(grammar); explore(grammar_reader); logger.info("Exploration pass complete. Freezing vocabulary and finalizing encoders."); if (dump != null) { PrintWriter dump_writer = new PrintWriter(dump); dump_writer.println(types.toString()); dump_writer.close(); } types.inferTypes(this.labeled); logger.info("Type inference complete."); logger.info("Finalizing encoding."); logger.info("Writing encoding."); types.write(output + File.separator + "encoding"); logger.info("Freezing vocab."); Vocabulary.freeze(); logger.info("Writing vocab."); Vocabulary.write(output + File.separator + "vocabulary"); // Read previously written encoder configuration to match up to changed // vocabulary id's. logger.info("Reading encoding."); encoderConfig = new EncoderConfiguration(); encoderConfig.load(output + File.separator + "encoding"); logger.info("Beginning packing pass."); Queue<PackingFileTuple> slices = new PriorityQueue<PackingFileTuple>(); // Actual binarization pass. Slice and pack source, target and data. grammar_reader = new LineReader(grammar); if (packAlignments) alignment_reader = new LineReader(alignments); binarize(grammar_reader, alignment_reader, slices); logger.info("Packing complete."); logger.info("Packed grammar in: " + output); logger.info("Done."); }