diff --git a/chatbot_complet.py b/chatbot_complet.py index ec9663158637e33339fbaca410ff08fe3cc4ee9a..489221faa40cde43df0ff7a8a766f717287a8c2b 100644 --- a/chatbot_complet.py +++ b/chatbot_complet.py @@ -23,14 +23,14 @@ def extract_keywords_textblob_french(sentence): 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] 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 - vectorizer = TfidfVectorizer() + vectorizer = TfidfVectorizer() #a tester en option : stop_words=list(stopwords.words('french')) vectorial_base = vectorizer.fit_transform(filtered_lines).toarray() feature_names = vectorizer.get_feature_names_out() @@ -42,7 +42,7 @@ def get_best_answers(question, text_lines, vectorizer, vectorial_base): # Calculate cosine similarity between the question and each text line 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] # Retrieve the corresponding text lines best_answers = [text_lines[i]+"\n" for i in top_indices] @@ -127,6 +127,7 @@ class ChatbotInterface(QWidget): left_layout = QVBoxLayout() left_layout.addWidget(self.conversation_text) left_layout.addWidget(self.user_input_entry) + # Ajouter le bouton "Envoyer" avec une taille réduite self.send_button.setMaximumWidth(self.send_button.width() // 3) left_layout.addWidget(self.send_button, alignment=Qt.AlignRight) @@ -141,7 +142,7 @@ class ChatbotInterface(QWidget): self.conversation_text.setSizePolicy(size_policy) # 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.setWindowTitle('chatbot') self.setGeometry(100, 100, 800, 600) @@ -167,6 +168,7 @@ class ChatbotInterface(QWidget): """) + self.user_input_entry.returnPressed.connect(self.send_message) self.history_list_widget.itemClicked.connect(self.history_item_clicked) @@ -223,7 +225,7 @@ if __name__ == '__main__': new_width = screen.availableGeometry().width() // 2 chatbot_app.resize(new_width, int(screen.availableGeometry().height()*15/16)) - # Centrer la fenêtre + # Centrer la fenêtre center_point = screen.availableGeometry().center().x()-chatbot_app.rect().center().x() chatbot_app.move(center_point,0)