AIML how to check if the input string matches one from a map - aiml

I am trying to compare if the user's input matches the expected answer in AIML. I found this code that works well when the value is true but, for some reason I can't understand, fails when the match is false (there is no match for the and goes to UDC). If it worked, I could easily replace the second * with my maps result.
From: https://github.com/pandorabots/aiml-utilities/blob/master/lib/aimlstandardlibrary.aiml
<!-- STRING EQUALS-->
<category>
<pattern>XEQ * XS *</pattern>
<template>
<learn>
<category>
<pattern>
<eval>
<uppercase>XFALSE <star/></uppercase>
</eval>
</pattern>
<template>TRUE</template>
</category>
</learn>
<srai>XFALSE <star index="2"/></srai>
<learn>
<category>
<pattern>
<eval>
<uppercase>XFALSE <star/></uppercase>
</eval>
</pattern>
<template>FALSE</template>
</category>
</learn>
</template>
</category>
Does anyone have a better way to do it? Thanks a lot.

Did you include the entire library AIML file? You need this category for it to work (it's at the top of the file):
<category>
<pattern>
XFALSE *
</pattern>
<template>FALSE</template>
</category>
Without it, the UDC will be called. A more efficient method would be to use the condition tag. This removes the need to use the <learn> tag to set up extra categories:
<category>
<pattern>XEQ * XS *</pattern>
<template>
<think>
<set name="value1"><star/></set>
<set name="value2"><star index="2"/></set>
</think>
<condition name="value1">
<li><value><get name="value2"/></value>TRUE</li>
<li>FALSE</li>
</condition>
</template>
</category>

Related

AIML not printing anything within this one condition loop; XCAR in nested category inside that condition loop treating input sentence as a single word

Using the standard library.
The code looks like <srai>XCAR AB, CD</srai>
But the stack trace shows [0] srai of XCAR AB,CD with the space removed.
Using Pandorabots.com.
I'm trying to loop though a string of , -delineated words of uniform length using XSUBSTRING, in order to map each one to a human-readable output.
So I'm using a nested category to get and print the XCAR of each XSUBSTRING based on the updated index predicate from the outer category.
Here's the code for the outer category:
<category>
<pattern>COMMAND</pattern>
<template>
<think>
<set name="index">0</set>
<set name="allitemsprinted">FALSE</set>
</think>
This part prints for me.
<br/><br/>
So does this.
<!-- iterate through "ties" -->
<condition name="allitemsprinted" value="FALSE">
But this doesn't print.
Nor does anything after.
This srai works correctly:
<srai>XCDR UX, SE, CS</srai>
<srai>PRINT ITEM</srai>
<loop/>
</condition>
<br/>
</template>
</category>
And here's the nested category:
<category>
<pattern>PRINT ITEM</pattern>
<template>
<think>
<set var="itemlocation">
<!-- 2-char name plus delim -->
<srai>XMUL <get name="index"/> XS 4</srai>
</set>
<set var="remainingitems">
<srai>XSUBSTRING <get name="items"/> XS <get var="itemlocation"/></srai>
</set>
<!-- increment index -->
<set name="index">
<map name="successor">
<get name="index"/>
</map>
</set>
<!-- check for end of list -->
<set name="allitemsprinted">
<srai>XGT <get name="index"/> XS <get name="itemcount"/></srai>
</set>
</think>
Remaining items: <get var="remainingitems"/>
First remaining item: <srai>XCAR <get var="remainingitems"/></srai>
<!-- human-readable output -->
<map name="itemsreadable">
<srai>XCAR <get var="remainingitems"/></srai>
</map>
<br/>
</template>
</category>
The stack trace provided by Pandorabots shows that the <srai> inside the <condition> does indeed get called. But it won't print anything at all.
First, make sure normal.substitution has an entry for removing commas [",", ""], as it's very rare that the bot needs to process commas.
Assuming your map is something like this:
[
["UX", "User Experience"],
["SE", "Sales Entry"],
["CS", "Customer Services"]
]
You can then do this to get human readable output (you don't need the standard library for this):
<category>
<pattern>COMMAND</pattern>
<template>
<think><set name="itemlist">UX, SE, CS</set></think>
<srai>PRINT ITEM <get name="itemlist"/></srai>
</template>
</category>
<category>
<pattern>PRINT ITEM * *</pattern>
<template>
<map name="itemsreadable"><star/></map><br/>
<srai>PRINT ITEM <star index="2"/></srai>
</template>
</category>
<category>
<pattern>PRINT ITEM *</pattern>
<template>
<map name="itemsreadable"><star/></map>
</template>
</category>
This will produce the following:

SAS Parameter logconfigloc and conventional log output

I got the task to log user access to datasets in certain libraries.
To solve this I use the SAS Audit logger, which already provides the desired output.
To get this desired output, i use the start parameter logconfigloc with the following XML-file:
<?xml version="1.0" encoding="UTF-8"?>
<logging:configuration xmlns:logging="http://www.sas.com/xml/logging/1.0/">
<!-- Log file appender with immediate flush set to true -->
<appender name="AuditLog" class="FileAppender">
<param name="File" value="logconfig.xml.win.audit.file.xml.log"/>
<param name="ImmediateFlush" value="true" />
<filter class="StringMatchFilter">
<param name="StringToMatch" value="WORK"/>
<param name="AcceptOnMatch" value="false"/>
</filter>
<filter class="StringMatchFilter">
<param name="StringToMatch" value="Libref"/>
<param name="AcceptOnMatch" value="true"/>
</filter>
<!-- The DenyAllFilter filters all events not fullfilling the criteria of at least one filters before -->
<filter class="DenyAllFilter">
</filter>
<layout>
<param name="ConversionPattern"
value="%d - %u - %m"/>
</layout>
</appender>
<!-- Audit message logger -->
<logger name="Audit" additivity="false">
<appender-ref ref="AuditLog"/>
<level value="trace"/>
</logger>
<!-- root logger events not enabled -->
<root>
</root>
</logging:configuration>
My Problem is, that by using the logconfigloc parameter, the log parameter is not working any more hence I get no "conventional" SAS log.
I allready tried to enable the root logger, but it´s output only looks similar to the original logfiles but has some diffrences.
Is there an (easy) way to get the "conventional" SAS log in addition the to the afforementioned special access logging output?
Kind Regards,
MiKe
I found the answer to the question how to obtain the conventional log.
For this purpose the SAS logger named "App" with message level "info" can be used.
So the following XML does the trick:
<?xml version="1.0" encoding="UTF-8"?>
<logging:configuration xmlns:logging="http://www.sas.com/xml/logging/1.0/">
<appender name="AppLog" class="FileAppender">
<param name="File" value="D:\Jobs_MK\SAS_Logging_Facility\Advanced_Logging_Test_with_XML\logconfig_standard_log.log"/>
<param name="ImmediateFlush" value="true" />
<layout>
<param name="ConversionPattern"
value="%m"/>
</layout>
</appender>
<!-- Application message logger -->
<logger name="App" additivity="false">
<appender-ref ref="AppLog"/>
<level value="info"/>
</logger>
<!-- root logger events not enabled -->
<root>
</root>
</logging:configuration>

QT XML reader reads the same tag everytime

I try to read an XML file and the reader reads it well, until it reads one specific tag (the close tag of Categories) and afterwards it read this tag infinite times.
This is the xml file:
<?xml version="1.0" encoding="utf-8"?>
<MovieMain MovieName="movie1" Version="1.29746.011215">
<FrameGroups FirstFrame="START" LastFrame="END">
<GroupFramesDescription>ALL MOVIE</GroupFramesDescription>
<frames Framenumber="1" >
<ObjectsGroup Name="1">
<LeftUpCorner X="30" Y="124" Z="0" />
<RightDownCorner X="53" Y="160" Z="0" />
<InfoAtt AttName="INDEX" AttInfo="1" />
<Categories>
<Category Name="computer" Probability="0.79" />
<Category Name="pen" Probability="0.7" />
<Category Name="desktop" Probability="0.1" />
<Category Name="mug" Probability="0.09" />
</categories>
</ObjectsGroup>
</frames>
</FrameGroups>
</MarkingChanges>
<ChangesList UserName="ooo" Date="12/3/2015" ChangesetIndex="1" />
</MarkingChanges>
</MovieMain>
And this is the function that I call to read the next element:
orXmlReader->readNextStartElement();
It gives me every time the next element till the close tag of Categories and than it read it again and again (I tried a loop of 100 times...).
I hope that you will help me as soon as you can,
Thanks.
Opening tag is <Categories> and closing is </categories> , i believe that search is case sensitive. Can you try with </Categories> as closing tag?

Regex validation in struts2

I need to validate an code field in struts2 with xml file validation.
I've got the regex expression, and it works.
I would like to add a condition: It's also ok if the field is blank.
I've tried to use an AND operator in this way:
<field name="codeFiscale">
<field-validator type="regex">
<param name="expression"><![CDATA[^(?=^$)(?=[a-zA-Z]{6}[0-9]{2}[abcdehlmprstABCDEHLMPRST]{1}[0-9]{2}([a-zA-Z]{1}[0-9]{3})[a-zA-Z]{1})$]]></param>
<message key="error.CF.invalid" />
</field-validator>
</field>
but it doesn't work. Any suggestion?
Using OR operator
<field name="codeFiscale">
<field-validator type="regex">
<param name="expression"><![CDATA[(?:^\\s*$)|(^[a-zA-Z]{6}[0-9]{2}[abcdehlmprstABCDEHLMPRST]{1}[0-9]{2}([a-zA-Z]{1}[0-9]{3})[a-zA-Z]{1}$)]]></param>
<message key="error.CF.invalid" />
</field-validator>
</field>
Don't you mean an OR operator? You want "either your first experession OR blank".
Try something like:
(?:firstExpression)?(blank?)
i will work fine
<param name="expression">^[0-9]{10}$</param> there is a bug.
<field name="contact">
<field-validator type="regex">
<param name="regex">^[0-9]{10}$</param>
<message>Invalid contact Number(10 digit)</message>
</field-validator>
</field>

Magento 1.5.01 - I am unable to load a template after overriding the customer module

This is my first post here, so please forgive me in advance :)
I've been working on overriding the Customer module for some specific
functionality depending on the user group; I want to duplicate and
append to the user registration form that targets the specific user
group.
I have successfully overridden and extended my way through the
controller, model, and block classes that I would like to use, however
when I override the block class, the layout i'm pointing to is no
longer rendered.
Here's the relevant chunk of the layout code:
<customer_account_vcreate translate="label">
<label>Customer Account Registration Form</label>
<!-- Mage_Customer -->
<remove name="right"/>
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml">
<block type="page/html_wrapper" name="customer.form.register.fields.before" as="form_fields_before" translate="label">
<label>Form Fields Before</label>
</block>
</block>
</reference>
</customer_account_vcreate>
I know that it just points to the regular block/template right now, but even that isn't loading. The block loads just fine (I can output from the constructor), it just seems that the layout file is not being loaded anymore.
I've also tried to override the login form with similar problems, can anyone help?
Geoff
EDIT -
Here's a more complete question for the login block:
Here's my config:
<?xml version="1.0"?>
<config>
<modules>
<Izoox_Customer>
<version>1.0.1</version>
</Izoox_Customer>
</modules>
<frontend>
<routers>
<customer>
<args>
<modules>
<Izoox_Customer before="Mage_Customer">Izoox_Customer_Customer</Izoox_Customer>
</modules>
</args>
</customer>
</routers>
<layout>
<updates>
<customer>
<file>izooxcustomer.xml</file>
</customer>
</updates>
</layout>
</frontend>
<global>
<blocks>
<customer>
<rewrite><form_login>Izoox_Customer_Block_Form_Login</form_login>
</rewrite>
</customer>
</blocks>
</global>
</config>
It works when I remove the block code from the above config, except then I'm not getting any of my custom code from the block.
Above I have overridden the Customer module to use my own code here, and have overridden the customer_login block with my own block. I can see that the custom block loads by echoing out of the _prepareLayout() function, but the view file (login.phtml) doesn't seem to load. Here's the layout (izooxcustomer.xml), which also loads fine.
<customer_account_login translate="label">
<label>Customer Account Login Form</label>
<!-- Mage_Customer -->
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/>
</reference>
</customer_account_login>
Am I missing something, or is this just not possible?
Thanks,
Geoff
Looks like you have your main layout tag misspelled. It should be <customer_account_create>. You have a 'v' in there before create.