How can we use AIML for making a chatbot? - aiml

Can we give random responses for a single question in AIML. For "Hi", I need random replies like "hey", "hello", "hi", etc.

AIML can be used for making chatbots. But you have to make templates for all possible questions user could possibly ask. Here is an example for AIML random responses
<pattern>HI</pattern>
<template>
<random>
<li> Hello! </li>
<li> Hi </li>
<li> Hey </li>
</random>

Related

how do i calculate how many days until monday in aiml

I cannot get this aiml script for calculationg how many days from this day till Monday.
I make chatbots on botlibre.
I tried the code I am going to post.
<category>
<pattern>HOW MANY DAYS UNTIL monday</pattern>
<template>
<interval>
<jformat>ddddd </jformat>
<style>days</style>
<from><date jformat="ddddd"/></from>
<to>saturday</to>
</interval>
days until saturday.
</template>
</category>
I expect the aiml script to display in the chatbot response how many days
until Monday.
that worked thanks i needed that.
i made a chatbot named pioyu on botlibre that acquires likes,dislikes and opinion about why people like or dislike something.
she makes them her own.
That is how I make my chatbot seem more human.
It could acquire sentences of things people have as well if they tell it and make them it's
own.
Ok, so first we need to know what day it is and set it in a predicate called "day". The format part is UNIX strftime and is explained here: https://devhints.io/datetime
We then check the value of "day" and can display a suitable response, including saying "day" rather than "days" when it's Sunday.
<category>
<pattern>HOW MANY DAYS UNTIL MONDAY</pattern>
<template>
<think><set name="day"><date format="%A"/></set></think>
<condition name="day">
<li value="Monday">0 days </li>
<li value="Tuesday">6 days </li>
<li value="Wednesday">5 days </li>
<li value="Thursday">4 days </li>
<li value="Friday">3 days </li>
<li value="Saturday">2 days </li>
<li value="Sunday">1 day </li>
</condition>
until Monday.
</template>
</category>

How can I click on numeric buttons (onclick Event) using selenum in python?

I have a HTML code like this:
<ul aria-hidden="false" aria-labelledby="resultsPerPage-button" id="resultsPerPage-menu" role="listbox" tabindex="0" class="ui-menu ui-corner-bottom ui-widget ui-widget-content" aria-activedescendant="ui-id-2" aria-disabled="false" style="width: 71px;">
<li class="ui-menu-item">
<div id="ui-id-1" tabindex="-1" role="option" class="ui-menu-item-wrapper">20</div>
</li>
<li class="ui-menu-item"><div id="ui-id-2" tabindex="-1" role="option" class="ui-menu-item-wrapper ui-state-active">50</div>
</li>
<li class="ui-menu-item"><div id="ui-id-3" tabindex="-1" role="option" class="ui-menu-item-wrapper">100</div>
</li>
<li class="ui-menu-item"><div id="ui-id-4" tabindex="-1" role="option" class="ui-menu-item-wrapper">200</div>
</li>
</ul>
I want to click on "200". Can u help me? I used selenium in python 2.7
I tried doing this:
import time
time.sleep(10)
x=driver.find_element_by_link_text("200").click()
x.click()
time.sleep(8)
The problem here is that the element that contains the text 200 is not a "Link", but only a li tag which could work as a clickable element was defined on that site.
The documentation doesn't specify it directly, but "Link" means only a tags.
The idea is the same, but you'll have to find that element on a different way than thinking about as a Link. Using xpath would be I think the best way for this approach:
x = driver.find_element_by_xpath("//div[./text()='200']")
x.click()
Now of course that would work for finding an element depending on the text it contains, but for finding the specific node you want would be even easier and better to use the id, as it should always be unique:
x = driver.find_element_by_id('ui-id-4')
I can run it by use of "send_keys":
import time
number.click()
number.send_keys("200")
var200=driver.find_element_by_xpath("""//*[#id="ui-id-4"]""")
var200.click()

Foundation Joyride issues

I am trying to use Foundation's joyride in my website. I took the example on Zurbs homepage like this
<ol class="joyride-list" data-joyride>
<li data-id="firstStop" data-text="Next" data-options="tip_location: top; prev_button: false">
<p>Hello and welcome to the Joyride <br>documentation page.</p>
</li>
<li data-id="numero1" data-class="custom so-awesome" data-text="Next" data-prev-text="Prev">
<h4>Stop #1</h4>
<p>You can control all the details for you tour stop. Any valid HTML will work inside of Joyride.</p>
</li>
<li data-id="numero2" data-button="Next" data-prev-text="Prev" data-options="tip_location:top;tip_animation:fade">
<h4>Stop #2</h4>
<p>Get the details right by styling Joyride with a custom stylesheet!</p>
</li>
<li data-button="End" data-prev-text="Prev">
<h4>Stop #3</h4>
<p>It works as a modal too!</p>
</li>
and then in the javsScript I initialize it like this
$(document).foundation('joyride', 'start');
I get this error on my console,
Uncaught RangeError: Maximum call stack size exceeded
Any explanations on how I am getting this error?
Sounds like the page is missing an element for Joyride to attach to. Your code contains the JoyRide modals but doesn't contain an element to attach to.
Add
<div id="firstStop">First Stop</div>
to your HTML.
Here's a working demo.

Can I repeat unordered list tags for my type of situation?

I'd just like to ask if this coding method is still valid.
<div class="one-third column">
<ul class="nav-link">
<li class="button">Going to put code here.</li>
</ul>
</div>
<div class="one-third column">
<ul class="nav-link">
<li class="button">Going to put code here.</li>
</ul>
</div>
<div class="one-third column">
<ul class="nav-link">
<li class="button">Going to put code here.</li>
</ul>
</div>
As you can see I'm repeating the unordered lists inside of the div class. This is necessary for me because I'm using Skeleton boilerplate and I need them to be in 3 columns, with the unordered lists.
I tried putting the list items inside the divs, but the validator states you cannot put div tags inside the unordered lists. So I'm asking if this method is still okay for me to use, since this website will be used as a public template. If there's an alternative way I can code this, please let me know. Thank you.

XSL for-each layout problem

I have a fairly simple layout required.
<ul>
<li>Link</li>
</li>Link</li>
</ul
<ul>
<li>Link</link>
<li>Link</link>
</ul>
However I get:
<ul>
<li>Link</li>
</ul>
<ul>
</li>Link</li>
</ul
<ul>
<li>Link</link>
</ul>
<ul>
<li>Link</link>
</ul>
Im sorry I dont have the XSL to hand, network issues but thought id ask anyway with a brief explanation:
Essentially my xsl =
<for each select=x>
<ul>
<li>select=link</li>
</ul>
</for each>
Should I be doing:
<ul>
<for each select=x>
<li>select=link</li>
</for each>
</ul>
I also want to get a header for the list that is a result of grouping similar items,
<h3>select=header</h3>
<ul>
<for each select=x>
<li>select=link</li>
</for each>
</ul>
Am i babbling...
Should I be doing:
Yes, although you ideally also want an if around the whole thing so that in the event you don't have any items at all, you emit nothing, not even a ul with no items.
Am i babbling...
Yes :)