Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Alligators-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Monmege
Alligators-python
Commits
b48ee57f
Commit
b48ee57f
authored
Jun 14, 2022
by
Antonio MATTAR
Browse files
Options
Downloads
Patches
Plain Diff
-Added the old_alligator feature.
parent
c149129f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
image_maker.py
+20
-2
20 additions, 2 deletions
image_maker.py
main.py
+3
-3
3 additions, 3 deletions
main.py
parsing.py
+19
-1
19 additions, 1 deletion
parsing.py
with
42 additions
and
6 deletions
image_maker.py
+
20
−
2
View file @
b48ee57f
...
...
@@ -73,11 +73,29 @@ def get_concat_h_multi_resize(im_list, resample=Image.BICUBIC):
pos_x
+=
im
.
width
+
space_width
return
dst
def
createOldAlligator
():
old_alligator_img
=
Image
.
open
(
"
figures/old_alligator.png
"
)
return
old_alligator_img
def
createOldAlligatorFamily
(
terme
):
old_alli_img
=
createOldAlligator
()
family_img
=
createImage
(
terme
)
old_alli_img
=
old_alli_img
.
resize
((
max
(
family_img
.
image
.
width
,
old_alli_img
.
width
),
max
((
int
(
old_alli_img
.
height
*
family_img
.
image
.
width
/
old_alli_img
.
width
),
old_alli_img
.
height
)))
)
old_alligator_fam
=
Image
.
new
(
'
RGB
'
,
(
max
(
old_alli_img
.
width
,
family_img
.
image
.
width
),
old_alli_img
.
height
+
family_img
.
image
.
height
),
(
255
,
255
,
255
))
old_alligator_fam
.
paste
(
old_alli_img
,
((
max
(
old_alli_img
.
width
,
family_img
.
image
.
width
)
-
old_alli_img
.
width
)
//
2
,
0
))
old_alligator_fam
.
paste
(
family_img
.
image
,
(
0
,
old_alli_img
.
height
))
return
old_alligator_fam
def
createAppImage
(
terme
):
assert
(
logic
.
isApplication
(
terme
))
left
=
logic
.
getFirstTerm
(
terme
)
right
=
logic
.
getSecondTerm
(
terme
)
im1
=
createImage
(
left
)
if
logic
.
isApplication
(
right
):
im2
=
createOldAlligatorFamily
(
right
)
application
=
get_concat_h_multi_resize
([
im1
.
image
,
im2
])
else
:
im2
=
createImage
(
right
)
application
=
get_concat_h_multi_resize
([
im1
.
image
,
im2
.
image
])
return
application
...
...
This diff is collapsed.
Click to expand it.
main.py
+
3
−
3
View file @
b48ee57f
...
...
@@ -7,9 +7,9 @@ def run():
# image_maker.saveImage(x, "terme")
# x.show()
logic
.
beta_reduction_totale
(
parsing
.
parseTerm
(
input
(
"
Enter a term:
"
)))
# x = logic.new_var(
logic.freshVar()
)
# y = logic.new_var(
logic.freshVar()
)
# print(logic.to_string(logic.new_app(x,logic.new_app(x,x))))
# x = logic.new_var(
'x'
)
# y = logic.new_var(
'y'
)
# print(logic.to_string(logic.new_app(
y,logic.new_app(
x,logic.new_app(x,x))))
)
run
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
parsing.py
+
19
−
1
View file @
b48ee57f
...
...
@@ -154,10 +154,28 @@ def buildAbs(terme):
else
:
return
buildTerm
(
getTermFromParantheses
(
terme
,
0
))
def
extract_terms
(
text
):
terms
=
[]
current_term
=
""
in_parens
=
False
for
char
in
text
:
if
char
==
"
(
"
:
in_parens
=
True
elif
char
==
"
)
"
:
in_parens
=
False
elif
char
==
"
"
and
not
in_parens
:
terms
.
append
(
current_term
)
current_term
=
""
else
:
current_term
+=
char
if
current_term
:
terms
.
append
(
current_term
)
return
terms
def
buildApp
(
terme
):
assert
(
checkType
(
terme
)
==
APP
)
if
terme
[
0
]
!=
'
(
'
:
liste_de_termes
=
terme
.
split
(
'
'
)
liste_de_termes
=
extract_terms
(
terme
)
# print(terme)
# print(liste_de_termes)
n
=
len
(
liste_de_termes
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment