javacompressionburrows-wheeler-transform

Text Compression and Decompression using BWT


I want to ask that can we combine the BWT MTF and Huffman Algorithms to get higher compression rate in java? what will be the process? Error In Wriring of MTF file?

public class MTF{
    static File f=new File("MTF.txt");
public static File encode(String msg, String symTable)throws Exception{
            if(!f.exists())
                f.createNewFile();
    StringBuilder s = new StringBuilder(symTable);
    for(char c : msg.toCharArray()){
        int idx = s.indexOf("" + c);
                    FileWriter writer = new FileWriter(f); 
                    writer.write(idx+" "); 
                    System.out.print(idx+" ");
                    writer.flush();
                    writer.close();
        s = s.deleteCharAt(idx).insert(0, c);
    }
            System.out.println("MTF done");
    return f;
}

Solution

  • It is quite easy to test this hypothesis, the process would be:

    In general: Applying MTF should improve compresability, as, for example mentioned here: http://michael.dipperstein.com/bwt/

    BWT is useful because it converts the data into a format that is generally more compressible by run length encoders and statistical encoders with order greater than 0. By additionally applying move-to-front coding, the data will be in a format which is generally more compressible by even zero order statistical encoders such as traditional implementations of Huffman coding or arithmetic coding.