Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
EEA
M1-EEA
Commits
e66bdb98
Commit
e66bdb98
authored
Mar 11, 2019
by
Pierre-antoine Comby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nettoyage du code et ajout dans le cours
parent
ab695aad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
28 deletions
+11
-28
455-Codage_Sources/Cours/chapA.tex
455-Codage_Sources/Cours/chapA.tex
+8
-5
455-Codage_Sources/algo_code/LZW.py
455-Codage_Sources/algo_code/LZW.py
+1
-5
455-Codage_Sources/algo_code/huffman2.py
455-Codage_Sources/algo_code/huffman2.py
+2
-18
No files found.
455-Codage_Sources/Cours/chapA.tex
View file @
e66bdb98
\documentclass
[main.tex]
{
subfiles
}
\begin{document}
\section
{
Codage d'Huffman
}
\section
{
Codage arithétique
}
\section
{
Codage LZW
}
\subsection
{
version objet
}
\inputminted
{
python
}{
../algo
_
code/huffman.py
}
\subsection
{
version simple
}
\inputminted
{
python
}{
../algo
_
code/huffman2.py
}
\section
{
Codage arithétique
}
\section
{
Codage LZW
}
\inputminted
{
python
}{
../algo
_
code/LZW.py
}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master:
t
%%% TeX-master:
main.tex
%%% End:
455-Codage_Sources/algo_code/LZW.py
View file @
e66bdb98
...
...
@@ -37,10 +37,6 @@ def decode_LZW(code,univers):
print
(
dictionnaire
)
return
''
.
join
(
msg
)
code
,
dictionnaire
=
code_LZW
(
message
,
univers
)
print
(
code
)
print
(
dictionnaire
)
msg
=
decode_LZW
(
code
,
univers
)
print
(
message
)
print
(
msg
)
print
(
code
,
dictionnaire
,
msg
)
455-Codage_Sources/algo_code/huffman2.py
View file @
e66bdb98
...
...
@@ -28,7 +28,6 @@ def create_tree(table_noeud):
root
=
Noeud
(
left
=
queue
[
0
],
right
=
queue
[
1
])
return
root
def
gen_code
(
node
,
prefix
=
''
):
def
gen_code_rec
(
node
,
prefix
=
''
):
if
node
.
left
!=
None
:
...
...
@@ -63,8 +62,6 @@ def make_tree():
f
.
write
(
'{rank =same; N'
+
'; N'
.
join
([
n
.
code
for
n
in
table_noeud
])
+
';}
\n
'
)
f
.
write
(
'}'
)
subprocess
.
call
(
'dot -Tpng graph.dot -o graph.png'
,
shell
=
True
)
print
(
'done'
)
def
decode_huffman
(
reverse
,
code
):
res
=
""
...
...
@@ -75,23 +72,10 @@ def decode_huffman(reverse, code):
text
=
text
[
len
(
k
):]
return
res
table
=
[
(
'A'
,
25
),
(
'B'
,
20
),
(
'C'
,
15
),
(
'D'
,
12
),
(
'E'
,
10
),
(
'F'
,
8
),
(
'G'
,
5
),
(
'H'
,
5
)]
table
=
[(
'A'
,
25
),(
'B'
,
20
),(
'C'
,
15
),(
'D'
,
12
),
(
'E'
,
10
),(
'F'
,
8
),(
'G'
,
5
),(
'H'
,
5
)]
table_noeud
=
[
Noeud
(
name
=
x
[
0
],
p
=
x
[
1
])
for
x
in
table
]
print
(
table_noeud
)
root_node
=
create_tree
(
table_noeud
)
print
(
root_node
)
x
=
gen_code
(
root_node
)
reverse_huffman
=
{
x
[
i
+
1
]:
x
[
i
]
for
i
in
range
(
0
,
len
(
x
)
-
1
,
2
)}
print
(
table_huffman
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment