My bad...I just used an online translator without checking it;
I hope this will help you :)
string QuestionsAddress = Directory.GetCurrentDirectory() + "\\Questions.xml";
string UnkownAddress = Directory.GetCurrentDirectory() + "\\Unkown.xml");
private void AddAQuestion(string question, string answer)
{
var document = XDocument.Load(QuestionsAddress);
foreach(var questions in document.GetElementByID("Question"))
{
int ID = questions.GetElementByID("ID");
}
XElement NewRecord = new XElement();
NewRecord =
if(ID.count == 0)
{
ID = 1;
}
for(ID=0;i<=ID.Count;i++)
{
question[i]+=question;
answer[i]+=answer;
}
AddAUnkonwnQuestion(question);
}
private void AddAUnkonwnQuestion(string question)
{
var document = XDocument.Load(UnkownAddress);
document.Root.Add(NewRecord)
document.Save(UnkownAddress)
}
void Main()
{
string question;
for (
;
;
) {
Console.Write("Your question:");
question = Console.ReadLine();
if ((question.Substring((question.Length - 1), 1) == "?"))
{
question = question.Substring(0, (question.Length - 1));
}
if ((question.Length > 0)) {
if ((question.IndexOf("newq:") == 0))
{
}
try {
AddAQuestion(question.Substring(5).Split("?")[0], question.Split("?")[1]);
Console.WriteLine("question is added");
Console.WriteLine("");
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
Console.WriteLine("Example question for add==>newq:is it a question?yes,it\'s");
}
Console.WriteLine("Example question for add==>newq:is it a question?yes,it\'s");
}
else
{
question.IndexOf("unknown:") = 0
{
Console.WriteLine("Ba tashakor az shoma ke az in chatbot estefade kardid");
Console.ReadKey();
}
}
}
}
}