Untitled
unknown
plain_text
2 years ago
1.9 kB
3
Indexable
#include <iostream> #include <string> #include <vector> #include <cstdlib> // srand, rand #include <ctime> // time std::vector<std::string> getChatbotResponses(const std::string& input) { std::vector<std::string> responses; if (input.find("naber") != std::string::npos) { responses.push_back("İyi, teşekkür ederim!"); responses.push_back("Selam! Sana nasıl yardımcı olabilirim?"); responses.push_back("Merhaba! Ne yapıyorsun?"); } else if (input.find("hava durumu") != std::string::npos) { responses.push_back("Hava durumu çok güzel bugün!"); responses.push_back("Hava durumu raporunu nereden öğrenmek istersiniz?"); responses.push_back("Bugün hava durumu biraz bulutlu olacak gibi görünüyor."); } else { responses.push_back("Anlamadım, ne demek istediğinizi açıklar mısınız?"); responses.push_back("Üzgünüm, anlamadım. Başka bir şeyler söyleyebilir misiniz?"); responses.push_back("Ne demek istediğinizi tam olarak anlamadım. Daha açıklayıcı olabilir misiniz?"); } return responses; } int main() { std::string userInput; while (true) { std::cout << "Kullanıcı: "; std::getline(std::cin, userInput); if (userInput == "exit") { break; } std::vector<std::string> chatbotResponses = getChatbotResponses(userInput); if (!chatbotResponses.empty()) { // Rastgele bir yanıt seçme std::srand(static_cast<unsigned int>(std::time(nullptr))); int randomIndex = std::rand() % chatbotResponses.size(); std::string chatbotResponse = chatbotResponses[randomIndex]; std::cout << "Chatbot: " << chatbotResponse << std::endl; } else { std::cout << "Chatbot: Üzgünüm, anlamadım." << std::endl; } } return 0; }
Editor is loading...