Mise à jour des commentaires de l'application Streamlit de recherche
This commit is contained in:
parent
53181a9eba
commit
edb8c2ea23
1 changed files with 22 additions and 15 deletions
|
@ -6,43 +6,43 @@ import plotly.express as px
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Set page config to wide mode
|
# Configurer la page en mode large
|
||||||
st.set_page_config(layout="wide")
|
st.set_page_config(layout="wide")
|
||||||
|
|
||||||
# Force dark theme
|
# Forcer le thème sombre
|
||||||
st.markdown("""
|
st.markdown("""
|
||||||
<style>
|
<style>
|
||||||
/* Main background */
|
/* Fond principal */
|
||||||
.stApp {
|
.stApp {
|
||||||
background-color: #0e1117;
|
background-color: #0e1117;
|
||||||
color: #fafafa;
|
color: #fafafa;
|
||||||
}
|
}
|
||||||
/* Sidebar */
|
/* Barre latérale */
|
||||||
.css-1d391kg {
|
.css-1d391kg {
|
||||||
background-color: #262730;
|
background-color: #262730;
|
||||||
}
|
}
|
||||||
/* Buttons */
|
/* Boutons */
|
||||||
.stButton>button {
|
.stButton>button {
|
||||||
color: #fafafa;
|
color: #fafafa;
|
||||||
background-color: #262730;
|
background-color: #262730;
|
||||||
border-color: #fafafa;
|
border-color: #fafafa;
|
||||||
}
|
}
|
||||||
/* Text inputs */
|
/* Champs de texte */
|
||||||
.stTextInput>div>div>input {
|
.stTextInput>div>div>input {
|
||||||
color: #fafafa;
|
color: #fafafa;
|
||||||
background-color: #262730;
|
background-color: #262730;
|
||||||
}
|
}
|
||||||
/* Selectbox */
|
/* Boîte de sélection */
|
||||||
.stSelectbox>div>div>select {
|
.stSelectbox>div>div>select {
|
||||||
color: #fafafa;
|
color: #fafafa;
|
||||||
background-color: #262730;
|
background-color: #262730;
|
||||||
}
|
}
|
||||||
/* Multiselect */
|
/* Sélection multiple */
|
||||||
.stMultiSelect>div>div>select {
|
.stMultiSelect>div>div>select {
|
||||||
color: #fafafa;
|
color: #fafafa;
|
||||||
background-color: #262730;
|
background-color: #262730;
|
||||||
}
|
}
|
||||||
/* Date input */
|
/* Saisie de date */
|
||||||
.stDateInput>div>div>input {
|
.stDateInput>div>div>input {
|
||||||
color: #fafafa;
|
color: #fafafa;
|
||||||
background-color: #262730;
|
background-color: #262730;
|
||||||
|
@ -50,7 +50,7 @@ st.markdown("""
|
||||||
</style>
|
</style>
|
||||||
""", unsafe_allow_html=True)
|
""", unsafe_allow_html=True)
|
||||||
|
|
||||||
# Add this CSS to create a scrollable results area
|
# Ajouter ce CSS pour créer une zone de résultats défilable
|
||||||
st.markdown("""
|
st.markdown("""
|
||||||
<style>
|
<style>
|
||||||
.scrollable-results {
|
.scrollable-results {
|
||||||
|
@ -138,7 +138,10 @@ if st.button('Rechercher'):
|
||||||
if 'facet_counts' in tous_resultats:
|
if 'facet_counts' in tous_resultats:
|
||||||
facettes_reseau = {facette['value']: facette['count'] for facette in tous_resultats['facet_counts'][0]['counts']}
|
facettes_reseau = {facette['value']: facette['count'] for facette in tous_resultats['facet_counts'][0]['counts']}
|
||||||
st.subheader("Résultats par Réseau")
|
st.subheader("Résultats par Réseau")
|
||||||
|
|
||||||
|
# Graphique en camembert pour montrer la distribution des résultats par réseau social
|
||||||
fig = px.pie(values=list(facettes_reseau.values()), names=list(facettes_reseau.keys()), title="Distribution par Réseau")
|
fig = px.pie(values=list(facettes_reseau.values()), names=list(facettes_reseau.keys()), title="Distribution par Réseau")
|
||||||
|
# Ce graphique montre la proportion de résultats pour chaque réseau social
|
||||||
st.plotly_chart(fig)
|
st.plotly_chart(fig)
|
||||||
|
|
||||||
# Distribution temporelle par réseau et par mois
|
# Distribution temporelle par réseau et par mois
|
||||||
|
@ -154,16 +157,20 @@ if st.button('Rechercher'):
|
||||||
df_temporel = df_temporel.groupby(['mois', 'network']).size().reset_index(name='count')
|
df_temporel = df_temporel.groupby(['mois', 'network']).size().reset_index(name='count')
|
||||||
df_temporel['mois'] = df_temporel['mois'].dt.to_timestamp()
|
df_temporel['mois'] = df_temporel['mois'].dt.to_timestamp()
|
||||||
|
|
||||||
|
# Graphique linéaire pour montrer l'évolution du nombre de posts par réseau au fil du temps
|
||||||
fig = px.line(df_temporel, x='mois', y='count', color='network',
|
fig = px.line(df_temporel, x='mois', y='count', color='network',
|
||||||
title="Distribution temporelle par réseau (agrégation mensuelle)")
|
title="Distribution temporelle par réseau (agrégation mensuelle)")
|
||||||
fig.update_layout(xaxis_title="Mois", yaxis_title="Nombre de posts")
|
fig.update_layout(xaxis_title="Mois", yaxis_title="Nombre de posts")
|
||||||
fig.update_xaxes(tickformat="%B %Y")
|
fig.update_xaxes(tickformat="%B %Y")
|
||||||
|
# Ce graphique permet de visualiser les tendances de publication pour chaque réseau social au fil des mois
|
||||||
st.plotly_chart(fig)
|
st.plotly_chart(fig)
|
||||||
|
|
||||||
|
# Graphique à barres empilées pour montrer la répartition des posts par réseau pour chaque mois
|
||||||
fig_bar = px.bar(df_temporel, x='mois', y='count', color='network',
|
fig_bar = px.bar(df_temporel, x='mois', y='count', color='network',
|
||||||
title="Distribution temporelle par réseau (barres empilées, agrégation mensuelle)")
|
title="Distribution temporelle par réseau (barres empilées, agrégation mensuelle)")
|
||||||
fig_bar.update_layout(xaxis_title="Mois", yaxis_title="Nombre de posts")
|
fig_bar.update_layout(xaxis_title="Mois", yaxis_title="Nombre de posts")
|
||||||
fig_bar.update_xaxes(tickformat="%B %Y")
|
fig_bar.update_xaxes(tickformat="%B %Y")
|
||||||
|
# Ce graphique permet de comparer facilement le volume de posts entre les différents réseaux sociaux pour chaque mois
|
||||||
st.plotly_chart(fig_bar)
|
st.plotly_chart(fig_bar)
|
||||||
|
|
||||||
st.subheader("Tableau récapitulatif mensuel")
|
st.subheader("Tableau récapitulatif mensuel")
|
||||||
|
@ -171,12 +178,13 @@ if st.button('Rechercher'):
|
||||||
df_pivot['Total'] = df_pivot.sum(axis=1)
|
df_pivot['Total'] = df_pivot.sum(axis=1)
|
||||||
df_pivot = df_pivot.reset_index()
|
df_pivot = df_pivot.reset_index()
|
||||||
df_pivot['mois'] = df_pivot['mois'].dt.strftime('%B %Y')
|
df_pivot['mois'] = df_pivot['mois'].dt.strftime('%B %Y')
|
||||||
|
# Ce tableau fournit un résumé détaillé du nombre de posts par réseau social pour chaque mois
|
||||||
st.dataframe(df_pivot)
|
st.dataframe(df_pivot)
|
||||||
|
|
||||||
# Create a string to hold all results
|
# Créer une chaîne pour contenir tous les résultats
|
||||||
all_results_text = ""
|
all_results_text = ""
|
||||||
|
|
||||||
# Populate the string with all results
|
# Peupler la chaîne avec tous les résultats
|
||||||
for hit in tous_resultats['hits']:
|
for hit in tous_resultats['hits']:
|
||||||
horodatage = hit['document']['creation_timestamp']
|
horodatage = hit['document']['creation_timestamp']
|
||||||
all_results_text += f"**{hit['document']['network']}** - {datetime.fromtimestamp(horodatage).strftime('%Y-%m-%d %H:%M:%S')}\n\n"
|
all_results_text += f"**{hit['document']['network']}** - {datetime.fromtimestamp(horodatage).strftime('%Y-%m-%d %H:%M:%S')}\n\n"
|
||||||
|
@ -188,6 +196,5 @@ if st.button('Rechercher'):
|
||||||
|
|
||||||
all_results_text += "---\n\n"
|
all_results_text += "---\n\n"
|
||||||
|
|
||||||
# Display the results in a text area
|
# Afficher les résultats dans une zone de texte
|
||||||
st.text_area("Résultats de la recherche", all_results_text, height=400)
|
st.text_area("Résultats de la recherche", all_results_text, height=400)
|
||||||
|
|
Loading…
Add table
Reference in a new issue