mswloch
Newbie
Posts: 1
Joined: Wed Mar 08, 2017 8:27 pm

Learning

Thu Mar 09, 2017 2:01 pm

Hello,

I have little problem with learning. Bot is not answering me learned thinks.. propably he is not learning becouse is not invoking lerning method.

CSharp Code

private BotAdam()
        {
            Chatbot = new SimlBot();
            Chatbot.Configuration.AllowLearning = true;
        
           // string file = File.ReadAllText(HostingEnvironment.MapPath(@"~/App_Data/SIML/Atomic.siml"));
            Chatbot.Learning += SimlBot_Learning;
            Chatbot.Memorizing += simlBot_Memorizing;
         
            foreach (var simlFile in Directory.GetFiles(HostingEnvironment.MapPath(@"~/App_Data/SIML"), "*.siml"))
            {
                var fileString = File.ReadAllText(simlFile);
                Chatbot.AddSiml(fileString);
            }

          
        }

        void simlBot_Memorizing(object sender, MemorizingEventArgs e)
        {
            var filePath = Path.Combine(HostingEnvironment.MapPath(@"~/App_Data/SIML"), e.User.ID, "Memorized.siml");
            e.Document.Save(filePath);
        }

        void SimlBot_Learning(object sender, LearningEventArgs e)
        {
            var filePath = HostingEnvironment.MapPath(@"~/App_Data/SIML/Learned.siml");
            e.Document.Save(filePath);
        }
my siml for learning:

SIML Code

<?xml version="1.0" encoding="utf-8"?>
<Siml>
  <Concept Name="Learning">
    <Model>
      <Pattern>* IS A *</Pattern>
      <Response>
        Alright I will keep that in mind.
        <Learn>
          <Concept Name="Learn" Type="Public" Repeat="True">
            <Model>
              <Pattern>What is an <Process><Match /></Process></Pattern>
              <Response>It's a <Process><Match Index="2" /></Process></Response>
            </Model>
 
          </Concept>
        </Learn>
      </Response>
    </Model> 
  </Concept>
</Siml>
i dont have any nulls. i can easly talk to bot but not learning him.
It can be problem with user? I dont have any license yet so i cant make user ;(

So i chat with bot by:

CSharp Code

var result = Chatbot.Chat(model.Text);
Console.WriteLine(result.BotMessage)
Why my bot want be stupid? Why he wont go to school?

User avatar
Fantom
Help & Support
Posts: 304
Joined: Fri Oct 25, 2013 9:20 pm

Re: Learning

Thu Mar 09, 2017 3:58 pm

I have tested your code and everything is working fine on my end. The Learning event is being triggered.

CSharp Code

var simlBot = new SimlBot();

//SIML File path containing your SIML code.
simlBot.AddSiml(XDocument.Load("forum.siml"));
simlBot.Learning += (sender, args) =>
{
	Console.WriteLine("Learning...");
	Console.WriteLine(args.Document.ToString());
};

var result = simlBot.Chat("apple is a fruit");
Console.WriteLine(result.BotMessage);
Could you check if your input matches the specified pattern and that the following code is indeed loading the SIML files.

CSharp Code

foreach (var simlFile in Directory.GetFiles(HostingEnvironment.MapPath(@"~/App_Data/SIML"), "*.siml"))
{
	var fileString = File.ReadAllText(simlFile);
	Chatbot.AddSiml(fileString);
}

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests