- 16 Ara 2010
- 176
- 0
İncelediğiniz zaman çok işinize yarayacak psikolog chat botu temel fonksiyonları seçili kelimeler varsa (hastalık) hastalığıyla ilgili soru soruyor yine seçili kelimeler (are ,and gibi) varsa 2 kere yazılma durumunda normalde do you love hello örneğin şeklinde soruyor hello yazarsa iki kez fakat seçili kelimelerde bunu çıkartıyor gibi bunların dışındaysa onaylama dinliyor gibi hissettirme tarzında inceleyince işinize yaracağını düşündüğüm için paylaşıyorum
Kod:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HomeworkFinal
{
class Program
{
static **** Main(string[] args)
{
bool[] flag = new bool[3];
bool shutdown = false;
int[] counters = new int[50];
string outputValue = " ";
string inputValue = " ";
char[] punctuations = { '.', ',', ';', '', '', '?', '!', '-', '{', '}', '(', ')', '[', ']' };
string[] stop_words = {"a", "after", "again", "all", "am", "and", "any", "are", "as", "at", "be", "been",
"before", "between", "both", "but", "by", "can", "could", "for", "from", "had", "has", "he", "her", "here",
"him", "in", "into", "I", "is", "it", "me", "my", "of", "on", "our", "she", "so", "such", "than", "that", "the",
"then", "they", "this", "to", "until", "we", "was", "were", "with", "you"
};
string[] negative_words = {"stress", "depression", "sad", "angry", "hate", "pain", "abnormal", "abort", "abuse",
"brittle", "hurt", "scared", "afraid", "upset", "confused", "lonely", "tired", "vulnerable", "guilty",
"anxiety", "disappointment", "regret", "awful", "sick", "regretful", "unhappy", "sorrowful", "troubled",
"worried", "annoyed"
};
while (!shutdown)
{
Console.Write("User : ");
inputValue = Console.ReadLine();
inputValue = inputValue.ToLower();
inputValue = inputValue.Replace('ı', 'i');
string[] input = inputValue.Split('.');
string[] eachone = inputValue.Split(' '); // her kelime burada tutuluyor.
for (int i = 0; i < eachone.Length; i++) //kural 1
{
for (int j = 0; j < eachone.Length; j++)
{
if (eachone[j] == eachone[i])
{
counters[i]++;
}
}
}
for (int i = 0; i < eachone.Length; i++)
{
for (int k = 0; k < stop_words.Length; k++) // bozuk
{
if (eachone[i] != stop_words[k] && counters[i] >= 2)
{
outputValue = "Computer : Do you love " + eachone[i] + " ";
counters[i] = 0;
flag[0] = true;
}
}
}
for (int i = 0; i < eachone.Length; i++) // kural 2
{
if (eachone[i].Contains("why") || eachone[i].Contains("who") || eachone[i].Contains("when")
|| eachone[i].Contains("where") || eachone[i].Contains("what") || eachone[i].Contains("how"))
{
Random choose = new Random();
int sayi = choose.Next(1, 3);
if (sayi == 1)
{
outputValue = "Computer : Do you often think about this question ?";
}
if (sayi == 2)
{
outputValue = "Computer : Why do you want to know?";
}
flag[1] = true;
}
}
for (int i = 0; i < negative_words.Length; i++) // kural 3
{
for (int k = 0; k < input.Length; k++)
{
if (input[k].Contains(negative_words[i]))
{
outputValue = "Computer : Being " + negative_words[i] + " is bad for your health. How long do you feel " + negative_words[i] + "? Why do you feel " + negative_words[i] + " ?";
flag[2] = true;
}
}
}
if (flag[0]==false && flag[1] == false && flag[2]==false) // kural 4
{
// me you
Random choose2 = new Random(); // her bir karakter için bak !!!
int sayi2 = choose2.Next(1, 3);
input[input.Length - 1] = input[input.Length - 1].Replace(" i ", " you ");
input[input.Length - 1] = input[input.Length - 1].Replace(" am ", " are ");
input[input.Length - 1] = input[input.Length - 1].Replace(" my ", " your ");
sayi2 = 1;
if (sayi2 == 1)
{
if(inputValue[inputValue.Length - 1]== '.' )
{
outputValue = "Computer : " + input[input.Length - 2] + ", right ?";
}
else
outputValue = "Computer : " + input[input.Length - 1] + ", right ?";
}
if (sayi2 == 2)
{
if (inputValue[inputValue.Length - 1] == '.')
{
outputValue = "Computer : You say " + input[input.Length - 2];
}
else
outputValue = "Computer : You say " + input[input.Length - 1];
}
}
Console.WriteLine(outputValue);
flag[0] = false;
flag[1] = false;
flag[2] = false;
}
Console.ReadLine();
}
}
}