The principal idea it's just save the letter as it comes and keep it in a dictionary of generated symbol and the frequency gave it, and of course I have a rule to make it adaptative but first I need to explain how it works.
Sequence Letter Symbol Frequency Current Output
-----------------------------------------------------------------------------------------------------------------------
1 A -> [a:0] [a:1] [a:0]
-----------------------------------------------------------------------------------------------------------------------
2 A -> [a:0] [a:2] [a:0]0
-----------------------------------------------------------------------------------------------------------------------
3 B -> [b:1] [b:1] [a:0]0[b:1]
-----------------------------------------------------------------------------------------------------------------------
4 C -> [c:01] [c:1] [a:0]0[b:1][c:01]
-----------------------------------------------------------------------------------------------------------------------
5 A -> [a:0] [a:3] [a:0]0[b:1][c:01]0
-----------------------------------------------------------------------------------------------------------------------
6 C -> [c:01] [c:2] [a:0]0[b:1][c:01]0,01
I didn't the code but I complete my design, that's all.
-----------------------------------------------------------------------------------------------------------------------
As you can see this is a way to compress ASCII text just using a dictionary and putting his own values in the compression, but here comes a question "Where is the adaptative?", well the adaptative form comes with this rule, when I have a letter with a certain percentage of the total of frequencies, then I switched the letter with minimum large of symbol and the minium frequency. Let's explain it.
Sequence Letter Symbol Frequency Current Output
-----------------------------------------------------------------------------------------------------------------------
7 C -> [c:01] [c:3] [a:0]0[b:1][c:01]0,01,01
-----------------------------------------------------------------------------------------------------------------------
8 C -> [c:01] [c:4] [a:0]0[b:1][c:01]0,01,01,01
-----------------------------------------------------------------------------------------------------------------------
7 C -> [c:01] [c:3] [a:0]0[b:1][c:01]0,01,01
-----------------------------------------------------------------------------------------------------------------------
8 C -> [c:01] [c:4] [a:0]0[b:1][c:01]0,01,01,01
-----------------------------------------------------------------------------------------------------------------------
9 C -> [c:01] [c:5] [a:0]0[b:1][c:01]0,01,01,01,01
-----------------------------------------------------------------------------------------------------------------------
10 C -> [c:1] [c:6] [a:0]0[b:1][c:01]0,01,01,01,01[c:1]
-----------------------------------------------------------------------------------------------------------------------
11 B -> [b:01] [b:2] [a:0]0[b:1][c:01]0,01,01,01,01[c:1]b[:2]
-----------------------------------------------------------------------------------------------------------------------
I didn't the code but I complete my design, that's all.
La explicación no es la más clara posible, pero la idea está bien. 0+3.
ResponderEliminar