Skip to content
Snippets Groups Projects
Commit a6440706 authored by Tiravy Amaury's avatar Tiravy Amaury
Browse files

commentaires

parent d215ad7a
No related branches found
No related tags found
1 merge request!6Test amau
...@@ -23,14 +23,14 @@ def extract_keywords_textblob_french(sentence): ...@@ -23,14 +23,14 @@ def extract_keywords_textblob_french(sentence):
return ' '.join(keywords) return ' '.join(keywords)
def create_vectorial_base(text_lines, min_chars=50): def create_vectorial_base(text_lines, min_chars=10):
filtered_lines = [line for line in text_lines if len(line) >= min_chars] filtered_lines = [line for line in text_lines if len(line) >= min_chars]
if not filtered_lines: if not filtered_lines:
print("No lines with at least 50 characters found.") print("No lines with at least 10 characters found.")
return None, None, None return None, None, None
vectorizer = TfidfVectorizer() vectorizer = TfidfVectorizer() #a tester en option : stop_words=list(stopwords.words('french'))
vectorial_base = vectorizer.fit_transform(filtered_lines).toarray() vectorial_base = vectorizer.fit_transform(filtered_lines).toarray()
feature_names = vectorizer.get_feature_names_out() feature_names = vectorizer.get_feature_names_out()
...@@ -42,7 +42,7 @@ def get_best_answers(question, text_lines, vectorizer, vectorial_base): ...@@ -42,7 +42,7 @@ def get_best_answers(question, text_lines, vectorizer, vectorial_base):
# Calculate cosine similarity between the question and each text line # Calculate cosine similarity between the question and each text line
similarities = cosine_similarity(question_vector, vectorial_base).flatten() similarities = cosine_similarity(question_vector, vectorial_base).flatten()
# Get the indices of the top 5 most similar text lines # Get the indices of the top 3 most similar text lines
top_indices = np.argsort(similarities)[-3:][::-1] top_indices = np.argsort(similarities)[-3:][::-1]
# Retrieve the corresponding text lines # Retrieve the corresponding text lines
best_answers = [text_lines[i]+"\n" for i in top_indices] best_answers = [text_lines[i]+"\n" for i in top_indices]
...@@ -127,6 +127,7 @@ class ChatbotInterface(QWidget): ...@@ -127,6 +127,7 @@ class ChatbotInterface(QWidget):
left_layout = QVBoxLayout() left_layout = QVBoxLayout()
left_layout.addWidget(self.conversation_text) left_layout.addWidget(self.conversation_text)
left_layout.addWidget(self.user_input_entry) left_layout.addWidget(self.user_input_entry)
# Ajouter le bouton "Envoyer" avec une taille réduite # Ajouter le bouton "Envoyer" avec une taille réduite
self.send_button.setMaximumWidth(self.send_button.width() // 3) self.send_button.setMaximumWidth(self.send_button.width() // 3)
left_layout.addWidget(self.send_button, alignment=Qt.AlignRight) left_layout.addWidget(self.send_button, alignment=Qt.AlignRight)
...@@ -141,7 +142,7 @@ class ChatbotInterface(QWidget): ...@@ -141,7 +142,7 @@ class ChatbotInterface(QWidget):
self.conversation_text.setSizePolicy(size_policy) self.conversation_text.setSizePolicy(size_policy)
# Définir la fenêtre principale # Définir la fenêtre principale
icon = QIcon("chatbot.png") # Remplacez par le chemin de votre icône icon = QIcon("chatbot.png")
self.setWindowIcon(icon) self.setWindowIcon(icon)
self.setWindowTitle('chatbot') self.setWindowTitle('chatbot')
self.setGeometry(100, 100, 800, 600) self.setGeometry(100, 100, 800, 600)
...@@ -167,6 +168,7 @@ class ChatbotInterface(QWidget): ...@@ -167,6 +168,7 @@ class ChatbotInterface(QWidget):
""") """)
self.user_input_entry.returnPressed.connect(self.send_message) self.user_input_entry.returnPressed.connect(self.send_message)
self.history_list_widget.itemClicked.connect(self.history_item_clicked) self.history_list_widget.itemClicked.connect(self.history_item_clicked)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment