Title: Windows Live Agents: Anything patterns II
Slug: windows-live-agents-anything-patterns-ii
Date: 2008-02-25 23:38:00
Author: Kartones
Lang: en
Tags: Development, Windows Live Agents
Description: The use of Anything patterns in Windows Live Agents.

 <p><span style="line-height: 1.428571429;">In </span><a href="https://blog.kartones.net/post/windows-live-agents-anything-patterns" style="line-height: 1.428571429;">a previous post</a><span style="line-height: 1.428571429;"> we talked about basic use of the Anything pattern.</span></p> <p>One "poltergeist" issue we may face is having an Anything pattern not catching long, multiple word user inputs. In our specific case it was only taking up to 4 word street names.</p> <p>Everything seems to be working perfectly, but "mysteriously" 5+ word street names are not taken, what is the problem or how do we solve it?</p> <p>Well, it took me a few to understand why wasn't working, and I found the answer looking at the BasicMatching.pkg library (where the Anything patterns are stored):</p> <p><font face="Courier New">subpattern Anything {minlength="1" maxlength="100" <b>score="MACRO_WEAK_SCORE"</b> style="raw"} </font> </p><p><font face="Courier New">subpattern AnythingWeaker {minlength="1" maxlength="100" <b>score="MACRO_WEAKER_SCORE"</b> style="raw"}</font>  </p><p><font face="Courier New">[...]</font>  </p><p>As I've marked in bold in the code fragment, the default <font face="Courier New">Anything</font> gets matched with something with a weak score (45 "points"), but there is a <font face="Courier New">AnythingWeaker</font> version which can handle even worse scorings (35 "points").  </p><p>This is logic, because long user inputs will probably not only be unmatched, but get lower scores than short ones (the different between existing patterns and failed one gets bigger as the input increases length).  </p><p>I've been able to capture 12 word user inputs using <font face="Courier New">AnythingWeaker</font>, so it should be enough... but for a real "catch-all", there is an unused score macro called <font face="Courier New">FAILED_SCORE</font> which captures inputs with 0 score :O</p>
