Research Article

n-Gram-Based Text Compression

Algorithm 3

Pseudocode of the force_four_gram_compression.
  input: The four-gram string, in this case is st4
  output: The encoded stream
() while  number of grams of st4 > 0  do
()    st3 += first gram of st4
()    delete first gram of st4
()    if  number  of  grams  of  st3 = 3  then
()         trigram_compression(st3)
()    end
() end
() force_trigram_compression(st3)