Spaces:
Sleeping
Sleeping
COULIBALY BOURAHIMA
commited on
Commit
·
d6a3367
1
Parent(s):
983896a
similarité
Browse files- App/functions_rupture/__pycache__/functions_gestion.cpython-311.pyc +0 -0
- App/utils/__pycache__/divers_function.cpython-311.pyc +0 -0
- App/utils/__pycache__/filter_dataframe.cpython-311.pyc +0 -0
- App/utils/__pycache__/login.cpython-311.pyc +0 -0
- App/utils/__pycache__/standadisation.cpython-311.pyc +0 -0
- App/utils/divers_function.py +79 -3
- App/utils/filter_dataframe.py +86 -0
- App/utils/login.py +0 -163
- App/utils/standadisation.py +17 -0
- app.py +24 -5
- pages/recherche.py +33 -0
- requirements.txt +2 -1
- rupture +0 -1
App/functions_rupture/__pycache__/functions_gestion.cpython-311.pyc
CHANGED
|
Binary files a/App/functions_rupture/__pycache__/functions_gestion.cpython-311.pyc and b/App/functions_rupture/__pycache__/functions_gestion.cpython-311.pyc differ
|
|
|
App/utils/__pycache__/divers_function.cpython-311.pyc
CHANGED
|
Binary files a/App/utils/__pycache__/divers_function.cpython-311.pyc and b/App/utils/__pycache__/divers_function.cpython-311.pyc differ
|
|
|
App/utils/__pycache__/filter_dataframe.cpython-311.pyc
ADDED
|
Binary file (4.26 kB). View file
|
|
|
App/utils/__pycache__/login.cpython-311.pyc
CHANGED
|
Binary files a/App/utils/__pycache__/login.cpython-311.pyc and b/App/utils/__pycache__/login.cpython-311.pyc differ
|
|
|
App/utils/__pycache__/standadisation.cpython-311.pyc
ADDED
|
Binary file (3.79 kB). View file
|
|
|
App/utils/divers_function.py
CHANGED
|
@@ -1,5 +1,12 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
@st.cache_data
|
| 5 |
def convert_df(df):
|
|
@@ -20,8 +27,6 @@ def supprime_country(df):
|
|
| 20 |
return df
|
| 21 |
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
def Merger(df, data_tr, produit_id, class_id):
|
| 26 |
keys = data_tr[produit_id].unique()
|
| 27 |
df_finale_v1 = df[df[produit_id].isin(keys)]
|
|
@@ -34,6 +39,77 @@ def Merger(df, data_tr, produit_id, class_id):
|
|
| 34 |
|
| 35 |
# Filtrer les lignes où 'class_id' a été modifié
|
| 36 |
merged_df = merged_df[merged_df[f'old_{class_id}'] != merged_df[f'{class_id}_y']]
|
| 37 |
-
finale_df = merged_df[["COUNTRY_KEY",
|
| 38 |
return finale_df
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
import re
|
| 4 |
+
from App.utils.standadisation import *
|
| 5 |
+
from nltk.corpus import stopwords
|
| 6 |
+
from nltk.stem import PorterStemmer
|
| 7 |
+
from nltk.stem.snowball import FrenchStemmer
|
| 8 |
+
from nltk.corpus import stopwords
|
| 9 |
+
|
| 10 |
|
| 11 |
@st.cache_data
|
| 12 |
def convert_df(df):
|
|
|
|
| 27 |
return df
|
| 28 |
|
| 29 |
|
|
|
|
|
|
|
| 30 |
def Merger(df, data_tr, produit_id, class_id):
|
| 31 |
keys = data_tr[produit_id].unique()
|
| 32 |
df_finale_v1 = df[df[produit_id].isin(keys)]
|
|
|
|
| 39 |
|
| 40 |
# Filtrer les lignes où 'class_id' a été modifié
|
| 41 |
merged_df = merged_df[merged_df[f'old_{class_id}'] != merged_df[f'{class_id}_y']]
|
| 42 |
+
finale_df = merged_df.drop(["_merge"], axis = 1) #[["COUNTRY_KEY" ,produit_id,"ITEM_DESC_x",f"old_{class_id}",f'{class_id[:-4]}_DESC_FR_x', f'{class_id}_y', f'{class_id[:-4]}_DESC_FR_y',"ITEM_DESC_y","nombre","total_by_ligne", "Proportion", "Countries","Poids"]]
|
| 43 |
return finale_df
|
| 44 |
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def data_cleaning(strings):
|
| 48 |
+
|
| 49 |
+
strings = strings.lower().strip()
|
| 50 |
+
strings = strings.replace('\'',' ')
|
| 51 |
+
strings = strings.replace('/',' ')
|
| 52 |
+
strings = re.sub(r'[^\w\s]', ' ', strings)
|
| 53 |
+
text_normalized = re.sub('[^A-Za-z ,éêèîôœàâ]+', ' ', strings)
|
| 54 |
+
|
| 55 |
+
return text_normalized
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def standardization(strings):
|
| 59 |
+
liste = strings.split(' ')
|
| 60 |
+
for i in range(len(liste)) :
|
| 61 |
+
if liste[i] in dictionnaire.keys():
|
| 62 |
+
liste[i] = dictionnaire[liste[i]]
|
| 63 |
+
return ' '.join(liste)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def remove_stop_words(strings):
|
| 67 |
+
liste_stopword_unicode = [str(item) for item in liste_stopword]
|
| 68 |
+
en_stops = set(stopwords.words('english') + liste_stopword_unicode)
|
| 69 |
+
fr_stops = set(stopwords.words('french') + liste_stopword_unicode)
|
| 70 |
+
|
| 71 |
+
list_DESCRIPTION = strings.split(' ')
|
| 72 |
+
cleaned_list = []
|
| 73 |
+
|
| 74 |
+
for ingredient in list_DESCRIPTION:
|
| 75 |
+
temp = ingredient.split(' ')
|
| 76 |
+
cleaned_ingredient = ' '.join([word for word in temp if word.lower() not in en_stops])
|
| 77 |
+
cleaned_list.append(cleaned_ingredient)
|
| 78 |
+
|
| 79 |
+
strings = ' '.join([ingredient for ingredient in cleaned_list])
|
| 80 |
+
list_DESCRIPTION = strings.split(' ')
|
| 81 |
+
cleaned_list = []
|
| 82 |
+
|
| 83 |
+
for ingredient in list_DESCRIPTION:
|
| 84 |
+
temp = ingredient.split(' ')
|
| 85 |
+
cleaned_ingredient = ' '.join([word for word in temp if word.lower() not in fr_stops])
|
| 86 |
+
cleaned_list.append(cleaned_ingredient)
|
| 87 |
+
|
| 88 |
+
strings = ' '.join([ingredient for ingredient in cleaned_list])
|
| 89 |
+
return strings
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
en_stemmer = PorterStemmer()
|
| 93 |
+
fr_stemmer = FrenchStemmer()
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def stem_sentence(sentence, stemmer):
|
| 97 |
+
words = sentence.split(' ')
|
| 98 |
+
stemmed_words = [stemmer.stem(word) for word in words]
|
| 99 |
+
stemmed_sentence = ' '.join(stemmed_words)
|
| 100 |
+
return stemmed_sentence
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def english_stemmer(strings):
|
| 104 |
+
list_ingredients = strings.split(' ')
|
| 105 |
+
stemmed_list = [stem_sentence(ingredient, en_stemmer) for ingredient in list_ingredients]
|
| 106 |
+
strings = ' '.join(stemmed_list)
|
| 107 |
+
return strings
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def french_stemmer(strings):
|
| 111 |
+
list_ingredients = strings.split(',')
|
| 112 |
+
stemmed_list = [stem_sentence(ingredient, fr_stemmer) for ingredient in list_ingredients]
|
| 113 |
+
strings = ' '.join(stemmed_list)
|
| 114 |
+
return strings
|
| 115 |
+
|
App/utils/filter_dataframe.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from pandas.api.types import (
|
| 4 |
+
is_categorical_dtype,
|
| 5 |
+
is_datetime64_any_dtype,
|
| 6 |
+
is_numeric_dtype,
|
| 7 |
+
is_object_dtype,
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def filter_dataframe(df: pd.DataFrame) -> pd.DataFrame:
|
| 13 |
+
"""
|
| 14 |
+
Adds a UI on top of a dataframe to let viewers filter columns
|
| 15 |
+
|
| 16 |
+
Args:
|
| 17 |
+
df (pd.DataFrame): Original dataframe
|
| 18 |
+
|
| 19 |
+
Returns:
|
| 20 |
+
pd.DataFrame: Filtered dataframe
|
| 21 |
+
"""
|
| 22 |
+
modify = st.checkbox("Add filters")
|
| 23 |
+
|
| 24 |
+
if not modify:
|
| 25 |
+
return df
|
| 26 |
+
|
| 27 |
+
df = df.copy()
|
| 28 |
+
|
| 29 |
+
# Try to convert datetimes into a standard format (datetime, no timezone)
|
| 30 |
+
for col in df.columns:
|
| 31 |
+
if is_object_dtype(df[col]):
|
| 32 |
+
try:
|
| 33 |
+
df[col] = pd.to_datetime(df[col])
|
| 34 |
+
except Exception:
|
| 35 |
+
pass
|
| 36 |
+
|
| 37 |
+
if is_datetime64_any_dtype(df[col]):
|
| 38 |
+
df[col] = df[col].dt.tz_localize(None)
|
| 39 |
+
|
| 40 |
+
modification_container = st.container()
|
| 41 |
+
|
| 42 |
+
with modification_container:
|
| 43 |
+
to_filter_columns = st.multiselect("Filter dataframe on", df.columns)
|
| 44 |
+
for column in to_filter_columns:
|
| 45 |
+
left, right = st.columns((1, 20))
|
| 46 |
+
left.write("↳")
|
| 47 |
+
# Treat columns with < 10 unique values as categorical
|
| 48 |
+
if is_categorical_dtype(df[column]) or df[column].nunique() < 10:
|
| 49 |
+
user_cat_input = right.multiselect(
|
| 50 |
+
f"Values for {column}",
|
| 51 |
+
df[column].unique(),
|
| 52 |
+
default=list(df[column].unique()),
|
| 53 |
+
)
|
| 54 |
+
df = df[df[column].isin(user_cat_input)]
|
| 55 |
+
elif is_numeric_dtype(df[column]):
|
| 56 |
+
_min = float(df[column].min())
|
| 57 |
+
_max = float(df[column].max())
|
| 58 |
+
step = (_max - _min) / 100
|
| 59 |
+
user_num_input = right.slider(
|
| 60 |
+
f"Values for {column}",
|
| 61 |
+
_min,
|
| 62 |
+
_max,
|
| 63 |
+
(_min, _max),
|
| 64 |
+
step=step,
|
| 65 |
+
)
|
| 66 |
+
df = df[df[column].between(*user_num_input)]
|
| 67 |
+
elif is_datetime64_any_dtype(df[column]):
|
| 68 |
+
user_date_input = right.date_input(
|
| 69 |
+
f"Values for {column}",
|
| 70 |
+
value=(
|
| 71 |
+
df[column].min(),
|
| 72 |
+
df[column].max(),
|
| 73 |
+
),
|
| 74 |
+
)
|
| 75 |
+
if len(user_date_input) == 2:
|
| 76 |
+
user_date_input = tuple(map(pd.to_datetime, user_date_input))
|
| 77 |
+
start_date, end_date = user_date_input
|
| 78 |
+
df = df.loc[df[column].between(start_date, end_date)]
|
| 79 |
+
else:
|
| 80 |
+
user_text_input = right.text_input(
|
| 81 |
+
f"Substring or regex in {column}",
|
| 82 |
+
)
|
| 83 |
+
if user_text_input:
|
| 84 |
+
df = df[df[column].str.contains(user_text_input)]
|
| 85 |
+
|
| 86 |
+
return df
|
App/utils/login.py
DELETED
|
@@ -1,163 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import bcrypt
|
| 3 |
-
import streamlit as st
|
| 4 |
-
import pandas as pd
|
| 5 |
-
from App.class_input_box.input_box import *
|
| 6 |
-
from App.functions_rupture.functions_gestion import *
|
| 7 |
-
from App.utils.divers_function import *
|
| 8 |
-
from App.utils.login import *
|
| 9 |
-
|
| 10 |
-
from streamlit_extras.chart_container import chart_container
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
def hash_password(password):
|
| 14 |
-
salt = bcrypt.gensalt()
|
| 15 |
-
hashed_password = bcrypt.hashpw(password.encode('utf-8'), salt)
|
| 16 |
-
return hashed_password
|
| 17 |
-
|
| 18 |
-
def validate_login(email, password):
|
| 19 |
-
state = SessionState.get(is_authenticated=False)
|
| 20 |
-
stored_email = "rupture-gestion" # Example stored email
|
| 21 |
-
stored_password =hash_password("Carrefour123!") # Example hashed password
|
| 22 |
-
|
| 23 |
-
if email == stored_email and bcrypt.checkpw(password.encode('utf-8'), stored_password):
|
| 24 |
-
state.is_authenticated = True
|
| 25 |
-
|
| 26 |
-
return state.is_authenticated
|
| 27 |
-
|
| 28 |
-
def login_page(state):
|
| 29 |
-
|
| 30 |
-
email = st.text_input("Email")
|
| 31 |
-
password = st.text_input("Password",type="password")
|
| 32 |
-
|
| 33 |
-
check_password = st.button('Login')
|
| 34 |
-
|
| 35 |
-
if check_password:
|
| 36 |
-
return validate_login(email,password)
|
| 37 |
-
return state.is_authenticated
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
@st.cache(suppress_st_warning=True, allow_output_mutation=True)
|
| 41 |
-
def main_() :
|
| 42 |
-
|
| 43 |
-
email, password, login = login_page()
|
| 44 |
-
|
| 45 |
-
if login:
|
| 46 |
-
if validate_login(email, password):
|
| 47 |
-
st.sidebar.success("Login successful!")
|
| 48 |
-
|
| 49 |
-
st.title("Gestion des ruptures ")
|
| 50 |
-
|
| 51 |
-
input_box = InputsBox()
|
| 52 |
-
data = input_box.get_data()
|
| 53 |
-
|
| 54 |
-
try:
|
| 55 |
-
if data.shape[0] != 0 :
|
| 56 |
-
st.header("Data")
|
| 57 |
-
|
| 58 |
-
st.dataframe(data)
|
| 59 |
-
|
| 60 |
-
"## Filters"
|
| 61 |
-
|
| 62 |
-
col1, col2 = st.columns(2)
|
| 63 |
-
|
| 64 |
-
with col1 :
|
| 65 |
-
product_id = input_box.get_product_id()
|
| 66 |
-
|
| 67 |
-
with col2 :
|
| 68 |
-
class_id = input_box.get_class_id()
|
| 69 |
-
|
| 70 |
-
col1, col2 = st.columns(2)
|
| 71 |
-
|
| 72 |
-
with col1 :
|
| 73 |
-
min_product_id = input_box.valid_produict_id()
|
| 74 |
-
|
| 75 |
-
with col2 :
|
| 76 |
-
vaind_class_id = input_box.valid_class_id()
|
| 77 |
-
|
| 78 |
-
conditions = input_box.conditions()
|
| 79 |
-
|
| 80 |
-
if st.button("RUN ", key="run_button"):
|
| 81 |
-
data = valide_key(data, product_id, class_id, min_product_id, vaind_class_id )
|
| 82 |
-
Country, merged = nouvelle_data(data,
|
| 83 |
-
str(product_id),
|
| 84 |
-
str(class_id))
|
| 85 |
-
|
| 86 |
-
merged_final = finale_merged(merged,
|
| 87 |
-
Country,
|
| 88 |
-
product_id,
|
| 89 |
-
class_id)
|
| 90 |
-
|
| 91 |
-
if conditions["Show data with ratios"]:
|
| 92 |
-
st.subheader("Show data with ratios")
|
| 93 |
-
st.dataframe(merged_final)
|
| 94 |
-
|
| 95 |
-
csv = convert_df(merged_final)
|
| 96 |
-
st.download_button(label="Download data as CSV",
|
| 97 |
-
data=csv,
|
| 98 |
-
file_name='sample_df.csv',
|
| 99 |
-
mime='text/csv',)
|
| 100 |
-
|
| 101 |
-
data_countries_ratio = cond_pays_proportion(merged_final,
|
| 102 |
-
conditions["Number of countries"],
|
| 103 |
-
conditions["Proportion"],
|
| 104 |
-
product_id)
|
| 105 |
-
|
| 106 |
-
df = supprime_country(data_countries_ratio)
|
| 107 |
-
csv = convert_df(df)
|
| 108 |
-
|
| 109 |
-
"""## The data below is filtered as follows: """
|
| 110 |
-
"- Number of countries greater than or equal to ", conditions["Number of countries"]
|
| 111 |
-
"- The proportion with the highest ", class_id ," is greater than or equal to ",conditions["Proportion"]
|
| 112 |
-
|
| 113 |
-
finale_df = Merger(data,
|
| 114 |
-
df,
|
| 115 |
-
product_id,
|
| 116 |
-
class_id)
|
| 117 |
-
|
| 118 |
-
tab1, tab2 = st.tabs(["Data without decision-making", "Data with proposed changes"])
|
| 119 |
-
|
| 120 |
-
with tab1 :
|
| 121 |
-
st.subheader("Data without decision-making")
|
| 122 |
-
st.dataframe(df)
|
| 123 |
-
st.download_button(label="Download data as CSV",
|
| 124 |
-
data=csv,
|
| 125 |
-
file_name='sample_df.csv',
|
| 126 |
-
mime='text/csv',)
|
| 127 |
-
|
| 128 |
-
with tab2 :
|
| 129 |
-
st.subheader("Data with proposed changes")
|
| 130 |
-
st.dataframe(finale_df)
|
| 131 |
-
csv_f = convert_df(finale_df)
|
| 132 |
-
st.download_button(label="Download data as CSV",
|
| 133 |
-
data=csv_f,
|
| 134 |
-
file_name='sample_df.csv',
|
| 135 |
-
mime='text/csv',)
|
| 136 |
-
|
| 137 |
-
"## Country priority "
|
| 138 |
-
|
| 139 |
-
priority_data = cond_pays_priorite(merged_final, product_id)
|
| 140 |
-
|
| 141 |
-
tab1, tab2 = st.tabs(["Data without decision-making", "Data with proposed changes"])
|
| 142 |
-
|
| 143 |
-
with tab1 :
|
| 144 |
-
st.subheader("Data without decision-making")
|
| 145 |
-
st.dataframe(priority_data)
|
| 146 |
-
csv_f = convert_df(priority_data)
|
| 147 |
-
st.download_button(label="Download data as CSV",
|
| 148 |
-
data=csv_f,
|
| 149 |
-
file_name='sample_df.csv',
|
| 150 |
-
mime='text/csv',)
|
| 151 |
-
|
| 152 |
-
with tab2 :
|
| 153 |
-
"to do"
|
| 154 |
-
|
| 155 |
-
except:
|
| 156 |
-
pass
|
| 157 |
-
st.write("An error occured. Please check your inputs.")
|
| 158 |
-
|
| 159 |
-
else:
|
| 160 |
-
st.error("Identifiant ou mot de passe incorrect !")
|
| 161 |
-
|
| 162 |
-
if __name__ == "__main__":
|
| 163 |
-
main_()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
App/utils/standadisation.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
dictionnaire = {"rg": "rouge","rges" : "rouge","rge": "rouge", "rse": "rose" ,"rs" : "rose", "bl": "blanc", "bdx": "Bordeaux",
|
| 2 |
+
"vdt": "vin de table", 'vdp': "vin de pays","blc": "blanc", "bib": "bag in box", "citr": "citron", "co": "coco", "gourm" : "gourmand",
|
| 3 |
+
"patis": "patisserie", "p'tits" : "petit", "p'tit": "petit","p tit": "petit", "pt": "pepite", "rev": "revil","succ": "sucettes",
|
| 4 |
+
"succet": "sucettes", "chocohouse": "choco house", "sach": "sachet", "choc": "choco", "tab" : "tablette", "hte" : "haute",
|
| 5 |
+
"spagh" : "spaghetti", "scht": "sachet", "nr": "noir", "caf": "cafe","barr": "barre", "pces": "pieces","pc": "pieces", "acidu": "acidule","blnc": "blanc",
|
| 6 |
+
"frui" : "fruit", "gourman" : "gourmand","bte" : "boîte", "bt" : "boîte", "ptit": "petit", "corb": "corbeil","ptits": "petit", "pti": "petit", "nois": "noisette",
|
| 7 |
+
"poul": "poulain", "barq" : "barquette", "barqu" : "barquette", 'fizz': 'fizzy', "st": "saint", "mich": "michel", "cal" : "calendrier", "calend" : "calendrier",
|
| 8 |
+
"calendr" : "calendrier", "caram" : "caramel", "cava" : "cavalier", "har" : "haribo", 'choc' : "chocolat", "choco" :"chocolat", 'lt' : "lait", "choc'n" :"chocolat noir",
|
| 9 |
+
"choc n" :"chocolat noir", "degust" : "degustation", "degus" : "degustation", "bis" : "biscuit", "coffr" : "coffret", "coff" : "coffret", "conf" : "confiserie",
|
| 10 |
+
"confis" : "confiserie", "croco" : "crocodile", "dble" : "double", "dess" : "dessert", "doyp" : "doypack", "harib" : "harib" , "et" : "etui", "exc" : "excellence",
|
| 11 |
+
"excel" : "excellence", "frit" : "friture","fritu" : "friture","fritur" : "friture", "gd" : "grand", "gr" : "grand", "grd" : "grand", "grchoc" : "grand chocolat", "lat" : "lait", 'ass' : "assorti", "assoti" :"assorti",
|
| 12 |
+
"noug" : "nougatine", "nougat" : "nougatine", "scht" : "sachet", "sct" : "secret", "cho" : "chocolat" , "bisc" : "biscuit", "am" : "amande", "liq" : "liqueur", "tabl" : "tablette","asst":"assorti",
|
| 13 |
+
"tab" : "tablette", "bil" : "bille", "vali" : "valisette", "cda" : "chevaliers d argouges", "tub": "tubo", "gril" :"grille", "amandesgrilles" : "amandes grilles", "ball" : "ballotin",
|
| 14 |
+
"piecestubo" : "pieces tubo"
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
liste_stopword = ['oz', 'kg', 'g', 'lb', 'mg', 'l', 'cl', 'ml', 'tsp', 'tbsp', 'cm', 'x', 'cte', 'h',"unknown"]
|
app.py
CHANGED
|
@@ -4,7 +4,23 @@ import time
|
|
| 4 |
from App.class_input_box.input_box import *
|
| 5 |
from App.functions_rupture.functions_gestion import *
|
| 6 |
from App.utils.divers_function import *
|
| 7 |
-
from App.utils.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def app():
|
|
@@ -18,7 +34,7 @@ def app():
|
|
| 18 |
if data.shape[0] != 0 :
|
| 19 |
st.header("Data")
|
| 20 |
|
| 21 |
-
st.dataframe(data)
|
| 22 |
|
| 23 |
"## Parameters"
|
| 24 |
|
|
@@ -181,13 +197,16 @@ def app():
|
|
| 181 |
|
| 182 |
except:
|
| 183 |
pass
|
| 184 |
-
st.error('This is an error', icon="🚨")
|
| 185 |
st.info('Ensure that column names are capitalized and that product_id and class_id descriptions are present, as well as a country column.', icon="ℹ️")
|
| 186 |
|
| 187 |
|
| 188 |
if __name__ == "__main__":
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
| 191 |
st.toast("Hello")
|
| 192 |
time.sleep(.5)
|
| 193 |
st.toast('An example of input is on the left')
|
|
|
|
| 4 |
from App.class_input_box.input_box import *
|
| 5 |
from App.functions_rupture.functions_gestion import *
|
| 6 |
from App.utils.divers_function import *
|
| 7 |
+
from App.utils.filter_dataframe import *
|
| 8 |
+
from App.utils.filter_dataframe import *
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# Page configuration
|
| 12 |
+
st.set_page_config(
|
| 13 |
+
page_title="Gestion des ruptures",
|
| 14 |
+
page_icon="logo.png",
|
| 15 |
+
layout="wide"
|
| 16 |
+
)
|
| 17 |
+
hide_streamlit_style = """
|
| 18 |
+
<style>
|
| 19 |
+
footer {visibility: hidden;}
|
| 20 |
+
</style>
|
| 21 |
+
"""
|
| 22 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
| 23 |
+
|
| 24 |
|
| 25 |
|
| 26 |
def app():
|
|
|
|
| 34 |
if data.shape[0] != 0 :
|
| 35 |
st.header("Data")
|
| 36 |
|
| 37 |
+
st.dataframe(filter_dataframe(data))
|
| 38 |
|
| 39 |
"## Parameters"
|
| 40 |
|
|
|
|
| 197 |
|
| 198 |
except:
|
| 199 |
pass
|
| 200 |
+
#st.error('This is an error', icon="🚨")
|
| 201 |
st.info('Ensure that column names are capitalized and that product_id and class_id descriptions are present, as well as a country column.', icon="ℹ️")
|
| 202 |
|
| 203 |
|
| 204 |
if __name__ == "__main__":
|
| 205 |
+
lien_label = "# Example of input"
|
| 206 |
+
lien_url = "https://docs.google.com/spreadsheets/d/123hVTOFpBT-C6mCnrOBh8fFIhSi8FxiuyHZJAQu8bDc/edit#gid=1220891905"
|
| 207 |
+
lien_html = f'<a href="{lien_url}">{lien_label}</a>'
|
| 208 |
+
|
| 209 |
+
st.sidebar.markdown(lien_html, unsafe_allow_html=True)
|
| 210 |
st.toast("Hello")
|
| 211 |
time.sleep(.5)
|
| 212 |
st.toast('An example of input is on the left')
|
pages/recherche.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
# Configuration
|
| 5 |
+
st.set_page_config(
|
| 6 |
+
page_title="Recherche",
|
| 7 |
+
page_icon="logo.png",
|
| 8 |
+
layout="wide",
|
| 9 |
+
initial_sidebar_state="auto"
|
| 10 |
+
|
| 11 |
+
)
|
| 12 |
+
change_footer_style = """
|
| 13 |
+
<style>
|
| 14 |
+
#MainMenu {visibility: hidden;}
|
| 15 |
+
footer {visibility: hidden;}
|
| 16 |
+
</style>
|
| 17 |
+
"""
|
| 18 |
+
st.markdown(change_footer_style, unsafe_allow_html=True)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def get_product_info(EAN):
|
| 22 |
+
url = f"https://world.openfoodfacts.org/api/v0/product/{EAN}.json"
|
| 23 |
+
response = requests.get(url)
|
| 24 |
+
if response.status_code == 200:
|
| 25 |
+
return response.json()
|
| 26 |
+
else:
|
| 27 |
+
return {"error": "Product not found"}
|
| 28 |
+
|
| 29 |
+
# Test de la fonction
|
| 30 |
+
EAN =st.text_input("EAN", '0737628064502') # remplacer par l'EAN du produit
|
| 31 |
+
if EAN :
|
| 32 |
+
product_info = get_product_info(EAN)
|
| 33 |
+
st.json(product_info)
|
requirements.txt
CHANGED
|
@@ -5,4 +5,5 @@ streamlit==1.25.0
|
|
| 5 |
streamlit_extras==0.3.0
|
| 6 |
gunicorn
|
| 7 |
nltk
|
| 8 |
-
bcrypt
|
|
|
|
|
|
| 5 |
streamlit_extras==0.3.0
|
| 6 |
gunicorn
|
| 7 |
nltk
|
| 8 |
+
bcrypt
|
| 9 |
+
re
|
rupture
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
Subproject commit a552d499acb5c1c855daf3e23e8d3582ec467f09
|
|
|
|
|
|