Commit c6c78c30 authored by ana's avatar ana

last details

parent 14c358be
......@@ -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
......
......@@ -11,7 +11,6 @@ import re
import pickle
dictionnaire1 = set()
print(type(dictionnaire1))
# function to find nouns
def find_nouns(citation):
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment