public static void Compress(string fromPath, string toPath, string toDictionaryPath, bool optimize = true) { using (WordCompressor compressor = WordCompressor.OpenWrite(toDictionaryPath)) { string firstWritePath = toPath; if (optimize) { firstWritePath = Path.ChangeExtension(toPath, ".tmp"); } // First Pass using (BufferedReader reader = new BufferedReader(File.OpenRead(fromPath))) using (BufferedWriter writer = new BufferedWriter(File.Create(firstWritePath))) { compressor.Compress(reader, writer); } // Optimize Pass if (optimize) { int[] map = compressor.OptimizeIndex(); using (BufferedReader reader = new BufferedReader(File.OpenRead(firstWritePath))) using (BufferedWriter writer = new BufferedWriter(File.Create(toPath))) { compressor.RewriteOptimized(map, reader, writer); } } } }
public static void Expand(string fromPath, string toPath, string fromDictionaryPath) { using (WordCompressor compressor = WordCompressor.OpenRead(fromDictionaryPath)) using (BufferedReader reader = new BufferedReader(File.OpenRead(fromPath))) using (BufferedWriter writer = new BufferedWriter(File.Create(toPath))) { compressor.Expand(reader, writer); } }
public static WordCompressor OpenRead(string dictionaryPath) { WordCompressor compressor = new WordCompressor(); using (BionReader reader = new BionReader(File.OpenRead(dictionaryPath))) { compressor.Read(reader); } return(compressor); }