Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,18 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import pipeline
|
3 |
import pandas as pd
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
7 |
|
8 |
-
#
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Labels candidats pour la classification
|
12 |
candidate_labels = ["commentaire positive", "commentaire négative"]
|
@@ -14,8 +20,12 @@ candidate_labels = ["commentaire positive", "commentaire négative"]
|
|
14 |
# Modèle de phrase pour la formation de l'hypothèse
|
15 |
hypothesis_template = "Cet exemple est un {}."
|
16 |
|
|
|
|
|
|
|
17 |
# Exécution de la classification seulement si du texte est entré
|
18 |
if text and candidate_labels: # Vérifier si du texte et au moins une étiquette sont présents
|
19 |
-
|
|
|
20 |
else:
|
21 |
st.write("Veuillez entrer du texte pour l'analyse.")
|
|
|
1 |
import streamlit as st
|
|
|
2 |
import pandas as pd
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
# Load the Comments.csv file
|
6 |
+
df = pd.read_csv("Comments.csv")
|
7 |
|
8 |
+
# Get the comments from the DataFrame
|
9 |
+
comments = df["comment"].tolist()
|
10 |
+
|
11 |
+
# Create a selectbox to choose a comment
|
12 |
+
selected_comment = st.selectbox("Select a comment", comments)
|
13 |
+
|
14 |
+
# Display the selected comment in the text input
|
15 |
+
text = st.text_input('Entrer le texte à analyser', value=selected_comment)
|
16 |
|
17 |
# Labels candidats pour la classification
|
18 |
candidate_labels = ["commentaire positive", "commentaire négative"]
|
|
|
20 |
# Modèle de phrase pour la formation de l'hypothèse
|
21 |
hypothesis_template = "Cet exemple est un {}."
|
22 |
|
23 |
+
# Create the classifier pipeline
|
24 |
+
classifier = pipeline("zero-shot-classification", model="morit/french_xlm_xnli")
|
25 |
+
|
26 |
# Exécution de la classification seulement si du texte est entré
|
27 |
if text and candidate_labels: # Vérifier si du texte et au moins une étiquette sont présents
|
28 |
+
result = classifier(text, candidate_labels, hypothesis_template=hypothesis_template)
|
29 |
+
st.info(f"Résultat: {result['labels'][0]} avec une confiance de {result['scores'][0]*100:.2f}%")
|
30 |
else:
|
31 |
st.write("Veuillez entrer du texte pour l'analyse.")
|