Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
Greffage des arbres
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
algolit
Greffage des arbres
Commits
c6c78c30
Commit
c6c78c30
authored
Sep 22, 2020
by
ana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
last details
parent
14c358be
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
30 deletions
+33
-30
creation_dictionnaire_a_partir_des_citations.py
creation_dictionnaire_a_partir_des_citations.py
+30
-28
etendre_dictionnaire_a_partir_des_definitions.py
etendre_dictionnaire_a_partir_des_definitions.py
+0
-1
greffer_des_arbres_sketch.py
greffer_des_arbres_sketch.py
+3
-1
No files found.
creation_dictionnaire_a_partir_des_citations.py
View file @
c6c78c30
...
...
@@ -36,34 +36,36 @@ def find_definition(nouns):
# convert Spacy syntax to string
nom
=
nom
.
text
# define webpage for specific noun
url
=
"https://www.larousse.fr/dictionnaires/francais"
urlpage
=
url
+
'/'
+
nom
print
(
"urlpage:"
,
urlpage
)
# find webpage
page
=
requests
.
get
(
urlpage
)
# get content
soup
=
BeautifulSoup
(
page
.
content
,
'lxml'
)
# find specific class of definitions
result
=
soup
.
find_all
(
'li'
,
class_
=
"DivisionDefinition"
)
# select definition 1
if
result
:
definition
=
str
(
result
[
0
])
#print("definition with tag:", definition)
if
definition
:
# remove example
example
=
': <span class="ExempleDefinition">'
if
example
in
definition
:
cutdefinition
=
definition
.
split
(
example
)
#print("cutdefinition:", cutdefinition)
definition
=
cutdefinition
[
0
]
# remove html tag
clean_definition
=
re
.
sub
(
"<(.+?)>"
,
""
,
definition
)
clean_definition
=
clean_definition
.
strip
()
clean
=
nom
,
clean_definition
#print('word + definition:', nom, clean_definition)
dictionnaire
.
add
(
clean
)
if
nom
not
in
dictionnaire
:
# define webpage for specific noun
url
=
"https://www.larousse.fr/dictionnaires/francais"
urlpage
=
url
+
'/'
+
nom
print
(
"urlpage:"
,
urlpage
)
# find webpage
page
=
requests
.
get
(
urlpage
)
# get content
soup
=
BeautifulSoup
(
page
.
content
,
'lxml'
)
# find specific class of definitions
result
=
soup
.
find_all
(
'li'
,
class_
=
"DivisionDefinition"
)
# select definition 1
if
result
:
definition
=
str
(
result
[
0
])
#print("definition with tag:", definition)
if
definition
:
# remove example
example
=
': <span class="ExempleDefinition">'
if
example
in
definition
:
cutdefinition
=
definition
.
split
(
example
)
#print("cutdefinition:", cutdefinition)
definition
=
cutdefinition
[
0
]
# remove html tag
clean_definition
=
re
.
sub
(
"<(.+?)>"
,
""
,
definition
)
clean_definition
=
clean_definition
.
strip
()
clean
=
nom
,
clean_definition
#print('word + definition:', nom, clean_definition)
dictionnaire
.
add
(
clean
)
return
dictionnaire
...
...
etendre_dictionnaire_a_partir_des_definitions.py
View file @
c6c78c30
...
...
@@ -11,7 +11,6 @@ import re
import
pickle
dictionnaire1
=
set
()
print
(
type
(
dictionnaire1
))
# function to find nouns
def
find_nouns
(
citation
):
...
...
greffer_des_arbres_sketch.py
View file @
c6c78c30
...
...
@@ -118,6 +118,8 @@ def greffes_qui_poussent(greffes, arbre):
# print("mot:", mot)
if
mot
in
arbre
:
definition
=
greffe
[
1
]
definition
=
definition
.
lower
()
definition
=
definition
.
strip
()
position
=
arbre
.
find
(
mot
)
# print("definition:", definition)
...
...
@@ -138,7 +140,7 @@ jardinier, arbre = choix_arbre(arbres)
short_bio
=
bio_offline
(
jardinier
)
# print("bref bio:", short_bio)
show
(
"L'arbre initial est une citation de {}{}{}
\n\n
"
.
format
(
bold
,
jardinier
,
reset
)
+
short_bio
,
5
)
show
(
"L'arbre initial est une citation de {}{}{}
\n\n
"
.
format
(
bold
,
jardinier
,
reset
)
+
short_bio
,
4
)
while
len
(
arbre
)
<
1500
:
...
...
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