how do i calculate how many days until monday in aiml - 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>

Related

AIML recognizing middle letter of any word

In aiml i am trying to make my bot recognize of middle letter of any word. for exemple if i ask "What is the middle letter of cat" then it should response "A" this is what code looks like
<category><pattern>MIDDLELETTER *</pattern>
<template>The middle letter of <star/> is: <srai>MIDDLEITEM <explode><star/></explode></srai></template>
</category>
<category><pattern>MIDDLEITEM * * *</pattern>
<template><srai>MIDDLEITEM <star index="2"/></srai></template>
</category>
<category><pattern>MIDDLEITEM *</pattern>
<template><star/></template>
</category>
The above code works fine in this scenario
HUMAN: MIDDLELETTER CAT
ROBOT: The middle letter of CAT is: A
HUMAN: MIDDLELETTER SKY
ROBOT: The middle letter of SKY is: K
But does not work properly in this case
HUMAN: MIDDLELETTER ROMAN
ROBOT: The middle letter of ROMAN is: O
HUMAN: MIDDLELETTER DCNOVAN
ROBOT: The middle letter of DCNOVAN is: C
I was expecting these kind of results
HUMAN: MIDDLELETTER ROMAN
ROBOT: The middle letter of ROMAN is: M
HUMAN: MIDDLELETTER DCNOVAN
ROBOT: The middle letter of DCNOVAN is: O
Also, what if if there are 8 letters in an word? i am expecting to make it work like
HUMAN: MIDDLELETTER ABSOLUTE
ROBOT: The middle letter of ABSOLUTE could be either O or L
What am i missing in my code?
To find the middle letter, you need to break up the word into individual letters and work out how long the word is. You can then use the length of the word to find the middle letter.
This method will work. For compatibility, I've assumed you have no math capabilities in your bot ie division. It works up to letters that are 11 letters long. For longer words, you should divide the word length by 2 to find the middle letter of a word.
<category>
<pattern>MIDDLELETTER *</pattern>
<template>
<think>
<set name="letternum">0</set>
<srai>BreakUpWord <explode><star/></explode></srai>
<condition name="letternum">
<li value="1"><set name="middle"><get name="char1"/></set></li>
<li value="2"><set name="middle"><get name="char1"/> or <get name="char2"/></set></li>
<li value="3"><set name="middle"><get name="char2"/></set></li>
<li value="4"><set name="middle"><get name="char2"/> or <get name="char3"/></set></li>
<li value="5"><set name="middle"><get name="char3"/></set></li>
<li value="6"><set name="middle"><get name="char3"/> or <get name="char4"/></set></li>
<li value="7"><set name="middle"><get name="char4"/></set></li>
<li value="8"><set name="middle"><get name="char4"/> or <get name="char5"/></set></li>
<li value="9"><set name="middle"><get name="char5"/></set></li>
<li value="10"><set name="middle"><get name="char5"/> or <get name="char6"/></set></li>
<li value="11"><set name="middle"><get name="char6"/></set></li>
</condition>
</think>
The middle letter of <star/> is <get name="middle"/>.
</template>
</category>
<category>
<pattern>BREAKUPWORD * *</pattern>
<template>
<srai>IncreaseLetternum <star/></srai>
<srai>BREAKUPWORD <star index="2"/></srai>
</template>
</category>
<category>
<pattern>BREAKUPWORD *</pattern>
<template>
<srai>IncreaseLetternum <star/></srai>
</template>
</category>
<category>
<pattern>INCREASELETTERNUM *</pattern>
<template>
<think>
<condition name="letternum">
<li value="0"><set name="letternum">1</set><set name="char1"><star/></set></li>
<li value="1"><set name="letternum">2</set><set name="char2"><star/></set></li>
<li value="2"><set name="letternum">3</set><set name="char3"><star/></set></li>
<li value="3"><set name="letternum">4</set><set name="char4"><star/></set></li>
<li value="4"><set name="letternum">5</set><set name="char5"><star/></set></li>
<li value="5"><set name="letternum">6</set><set name="char6"><star/></set></li>
<li value="6"><set name="letternum">7</set><set name="char7"><star/></set></li>
<li value="7"><set name="letternum">8</set><set name="char8"><star/></set></li>
<li value="8"><set name="letternum">9</set><set name="char9"><star/></set></li>
<li value="9"><set name="letternum">10</set><set name="char10"><star/></set></li>
<li value="10"><set name="letternum">11</set><set name="char11"><star/></set></li>
</condition>
</think>
</template>
</category>

How can we use AIML for making a chatbot?

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>

Incremental counter for <li> tags in XSLT

I'm using XSLT to pull some data from child nodes in an Umbraco (4.7) structure. That part is working fine, but I need to style each <li> item slightly different, so each one will be: <li id=x> where x is an integer between 1 and 15.
I've found a couple of methods for incrementing a counter value in XSLT, but I can't tell why it's not working as it should. Here's the relevant source:
<ul>
<xsl:for-each select="$currentPage/Solutions/SolutionsItem[#isDoc]">
<xsl:variable name="count">
<xsl:number/>
</xsl:variable>
<li id="$count">
<a><xsl:value-of select="solutionsItemTitle" /></a>
</li>
</xsl:for-each>
</ul>
When I review the HTML's source after running the XSLT, it just shows <li id=$count> rather than an integer. Can anyone suggest where to go from here?
You need an attribute value template <li id="{$count}">...</li> to compute the attribute value from the XPath expression.

ExpressionEngine 1.6.9: displaying a weblog at all pages

I'm a EE newbie.
I have the code below. the poll weblog displays at search result page, but doesn't display at blog and post details page :/ what am I missing?
display at search result page: www.blabla.com/search/noresults/d8ee432f229715a4adfbe1cc0d21049a/
NO display at blog pages: www.blabla.com/blog/ or www.blabla.com/blog/post/lorem_ipsum_is_simply_dummy_text/
Appreciate helps!!!! Thanks a lot!
{exp:weblog:entries weblog="lg_polls"}
{exp:lg_polls:poll entry_id="29" precision="1" return="/blog/"}
<p>{poll_question}</p>
{if can_vote}
{poll_form}
{if has_voted}<p>You have already voted in this poll, however you can vote again.</p>{/if}
<ul class='lg-polls-answers'>
{poll_answers}
<li class='a-{answer_count}'>
<label for='lg-polls-answer-{answer_id}'>{answer_input} <span class='answer'>{answer}</span></label>
</li>
{/poll_answers}
</ul>
<div class="alignCenter"><input type="image" src="{site_url}/images/btn_submitpoll.png" alt="Vote" /></div>
{/poll_form}
{if:else}
{if has_voted}<p>Thanks for voting in this poll.</p>{/if}
{if restricted}<p>Sorry, You are restricted from voting in this poll.</p>{/if}
{if expired}<p>This poll ended on {expiration_date}.</p>{/if}
{if yet_to_begin}<p>This poll is yet to begin. Voting opens on {entry_date}.</p>{/if}
{/if}
{if show_results}
<div class='lg-poll-results' id='lg-poll-results-29'>
<ul class='lg-polls-answers'>
{results_answers}
<li class='a-{answer_count}'>
<span class='answer'>{answer}</span>
<span class='answer-total-votes'>{answer_total_votes} votes <b>{answer_percentage}%</b></span>
</li>
{/results_answers}
</ul>
<div class='poll-total-votes'>Total Votes: {poll_total_votes}</div>
</div>
{if:else}
{if show_results_after_poll && has_voted}The results of the poll will be made available on {expiration_date}{/if}
{if never_show_results && has_voted}The results of this poll will be made public at a later date.{/if}
{/if}
{/exp:lg_polls:poll}
{/exp:weblog:entries}
I'm not 100% sure, since I haven't used LG Polls before, but try adding in dynamic="off" to your exp:weblog:entries opening tag. That will prevent EE from trying to find entries within the weblog you're calling based on the URL. See the link below:
http://expressionengine.com/legacy_docs/modules/weblog/parameters.html#par_dynamic

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 :)