Amazon Lex custom slot type issue using EXPANDED VALUES - amazon-lex

Our team has been developing a chatbot with Amazon Lex for around 3 months now and we need a slot type that will accept ANY last name. The built-in AMAZON.US_LASTNAME slot type appears to be limiting and we need every name to be accepted the first time they are entered.
We created and trained a last_name custom slot type with a significant enumerationValues list and set the slot resolution to EXPANDED VALUES to theoretically accept any value (I believe that’s how it works but happy to hear otherwise). Our last_name slot type is not accepting any last name that is not in our enumerationValues list, so it appears the EXPANDED VALUES resolution is not working as I understand it should be.
Any advice on how to create a custom slot that will accept any last name?

Related

Amazon Lex - receive spoken spelled out word, what slot type should I use?

Goal
User should spell out their name one letter at a time, for example: "s a r a h" / "ess ay are ay aych".
Lex should understand and convert it to text together: "sarah"
What I've tried
I'm using Amazon Connect (IVR/phone, user speaks into the phone to spell their name) which is using Lex to listen and convert to text.
I've tried a "AlphaNumeric" slot but it rarely works. I've also tried custom slots for all letters e.g. "a.", "b." - also rarely works.
Has anyone dealt with this? Any direction/experience would be appreciated re. handling spoken (not typed/chat bot) letter-by-letter input using Lex and preferably also Connect.
Other research I've done
https://forums.developer.amazon.com/questions/9331/letter-of-the-alphabet-slot-type.html - this author apparently took the custom letter slot approach, but doesn't really confirm if it worked overall. I've tried this and it's not working, but maybe I'm missing something important.
https://forums.aws.amazon.com/thread.jspa?threadID=261741 - AWS support thread which isn't very helpful
If you click the + next to Slot types you'll have the option to Extend slot type. If you click this you can create a new slot type with a regular expression based on your use case. For a first name that might be [a-z]{2,25}. I think the max length for these is 30, so [a-z]{1,40} would fail.

HL7 ADT Message parsing: date ranges

Note:
This question is not asking for advice on which library to use; I'm rolling my own.
I'm reading through the HL7 v2.5.1 spec in order to make a parsing engine for iOS and Windows.
My question is related to the Name Validity Range component in the Patient Name field (PID-5). But I think it applies generally to all DR (Date Range) components.
In Chapter 3: Patient Administration, on page 75, the following information is listed:
Components: {...omitted...} ^ <Name Validity Range (DR)> ^
{...omitted...}
Subcomponents for Name Validity Range (DR):
<Range Start Date/Time (TS)> & <Range End Date/Time (TS)>
Subcomponents for Range Start Date/Time (TS):
<Time (DTM)> & <Degree of Precision (ID)>
Subcomponents for Range End Date/Time (TS):
<Time (DTM)> & <Degree of Precision (ID)>
I understand how the fields, components and subcomponents are structured and how their separators are used... or at least I think I do. However, the above information confuses me as to how the data would be expressed. I have searched, but cannot find a suitable message sample for this kind of data. Based on my understanding of the HL7 data structures, here's how the data would be encoded:
PID|||01234||JONES^SUSIE^Q^^^^^^^199505011201&M&199505011201&M^199505011201&M&199505011201&M
The problem here, of course, is that having subcomponents embedded in subcomponents leaves you unsure exactly how to parse the data and what data goes where.
I did look into Chapter 2: Control, Appendix A and found this text on page 160:
Note: DR cannot be legally expressed when embedded within another data type. Its use is constrained to a segment field.
So, it appears that the standard listed for PID-5 is invalid. I haven't seen any messages from my system that even generate this information, so it may be a moot point for my particular case, but I don't like developing solutions with known holes. Has anybody encountered this "in the wild"?
An item with DR data type can be subdivided and have a precision subcomponent if the item is of type field .eg. ARQ/11 Requested start date/time range.
It can be subdivided in start and end of data range subcomponents but not precision subcomponent if the item with DR data type is already part of an other data type as in your example PID/5.
Patient name is an XPN data type which is a composite data type. That basically mean it can have a combination of Primary (like ST) and other Composites, as shown here
Now, you are looking at XPN.10 which is 10th component which is DR Data type, and again DR is combination of 2 primary DTM - start and end - or 2 subcomponents. And subcomponents are seperated by &.

Making custom slots using Regex in amazon Lex

I want to make custom slots that accepts any and all entries as long as those entries follow a certain regex pattern, eg:any number of alphabets or numbers but without a space in between. Can anyone tell me if there is a way in amazon lex to achieve it?
Also, if I want to take a certain type of data, say, email ids, but want to give the user option to give any number of email ids (more than one), what is the way to do that.
I am new to Amazon Lex and any suggestions would be appreciated.
Make a slot in Lex console in your intent but do not tick as required, and give any type as slot type.
Now in lambda code, first set the slot to null and then parse the inputText using regex and assign the correct value to the slot.
This way both of your problems will be addressed.
Hope it helps. Let us know if you run in any problems.

Why does Forth reserve two cells per variable?

While trying to find out how Forth manages the dictionary (and memory in general), I came across this page. Being familiar with C, I have no problem with the concept of pointers, and I assume I understood everything correctly. However, at the end of the page are several exercises, and here I noticed something strange.
Exercise 9.4, assuming DATE has been defined as a VARIABLE, asks what the difference is between
DATE .
and
' DATE .
and exercise 9.5 does the same using the user variable BASE.
According to the supplied answers, both phrases will give the same result (also with BASE). Trying this with Win32Forth however, gives results with a difference of 4 bytes (1 cell). Here is what I did:
here . 4494668 ok
variable x ok
x . 4494672 ok
' x . 4494668 ok
Creating another variable gives a similar result:
variable y ok
y . 4494680 ok
' y . 4494676 ok
Thus, it looks like each variable gets not just one cell (for the value), but two cells. The variable itself points to where the actual value is stored, and retrieving the contents at the execution token (using ' x ?) gives 0040101F for both variables.
For exercise 9.5, my results are:
base . 195F90 ok
' base . 40B418 ok
These are not even close to each other. The answer for this exercise does however mention that the results can depend on how BASE is defined.
Returning to normal variables, my main question thus is: why are two cells reserved per variable?
Additionally:
Since only one cell contains the actual value, what do the contents of the other cell mean?
Is this specific to Win32Forth? What happens in other implementations?
Is this different for run-time and compile-time variables?
How do answers to the above questions apply to user variables (such as BASE)?
EDIT1: Okay, so Forth also stores a header for each variable, and using the ' gives you the address of this header. From my tests I would then conclude the header uses just one cell, which does not correspond to all the information the header should contain. Secondly, according to the exercise retrieving the address of a variable should for both cases give the same result, which appears to contradict the existence of a header altogether.
My gut feeling is that this is all very implementation-specific. If so, what happens in Win32Forth, and what should happen according to the exercise?
This is roughly how a definition looks like in the dictionary using a traditional memory layout. Note that implementations may well diverge from this, sometimes a lot. In particular, the order of the fields may be different.
Link to previous word (one cell)
Flags (a few bits)
Name length (one byte, less a few bits)
Name string (variable)
Code field (one cell)
Parameter field (variable)
Everything except the code and parameter fields is considered the header. The code field usually comes right before the parameter field.
Ticking a word with ' gives you an XT, or execution token. This can be anything the implementation fancies, but in many cases it's the address of the code field.
Executing a word created with CREATE or VARIABLE gives you the address of the parameter field.
This is probably why in Win32Forth, the two addresses differ by 4 bytes, or one cell. I don't know why the answers to the exercises state there should be no difference.
Assuming BASE is a user variable, it probably works like this: Every task has its own user area in which user variables are allocated. All user variables know their specific offset inside this area. Ticking BASE gives you its XT, which is the same for all tasks. Executing BASE computes an address by adding its offset to the base of the user area.

Filemaker if dropdown contains text alter calculation

I am fairly sure stuff like this has been answered but I am losing my hair at the moment with this. I am using Filemaker Pro 13
I have been landed with the job of updating some templates, I have done this before but all I was doing was updating the visual side of things. Now I am wanted to dynamically update some labels and calculations depending on a 'Company selected(drop down with custom values that are all text).
Currently all costs are multiplied by 2. So if original cost = $4 then customer cost is $8. However if 'Company 4' is selected rather than being multiplied by 2 it needs to be multiplied by 1.5.
I currently have two functions that I am trying to use this functionality on a field box.
First function:
If (Company: = "Comp4"; 1;0)
Second function:
If (${Function1}; ${$Cost}*1.5; ${$Cost}*2 )
This does not work, hence the answering of this question. As far as I could understand if statements work as (Condintion; If true do X; Else do Y;). This may be the problem? I do come from a programming background but this program is irritating me beyond belief at the moment.
If this has been answered before then I offer my sincerest apologies.
Thank you for any answers or help pointing me into the right direction.
Edit: Just tried this:
If (ValueCount(FilterValues(Company;"Comp4"));${$Cost}*1.5; ${$Cost}*2)
This was to no avail. Ideally if I could fit this into one function that would be great but so far I am still failing.
Edit 2:
With regards to the function / functions not working. I would often only get the ${$Cost}*2 side of things would happen however the ${$Cost}*1.5 would not even when "Comp4" was selected. This made me think that it was either the system was not detecting "Comp4" was selected or I need to look elsewhere to find the value I need to look at.
Edit 3: Real values and calculations used
Currently used and working so to speak ( Just does the *2 aspect of things)
Field Name: x2$Charges
Calculation: ${$Charges}*2. - $Charges is the 'cost' fields (10 of them).
What I want to do is when a specific company is selected rather than doing cost *2 I want to do cost *1.5.
The check for said company is :
Field Name: x2CheckSSL
Calculation: If(Sales Rep.|Distributor: = "SSL";1.5;2)
Where Sales Rep.|Distributor: is 'Company'
It's difficult to tell what is wrong with your syntax, because we don't know the exact names of your fields. Also, "this does not work" is not a good description of a problem.
The fact that you have constructs like ${$Cost} indicates that you have invalid field names.
If you had fields named Company and Cost, then a calculation field (defined in the same table as these two fields) =
If ( Company = "Comp4" ; 1.5 ; 2 ) * Cost
should provide the expected result.
On a more general level, this is not a good approach to take. All of these factors {"Comp4", 1.5, 2} are data and should not be hard-coded into a calculation formula.
Properly, every company should have a markup value stored in its own record, and this would be looked up into a field when you select a company. Alternatively, only some (preferred) companies would have a markup, while others would use a default value stored in a preferences table.
In addition, the Company field in this table (Invoices?) should really be CompanyID and store only the (meaningless) ID of the selected company.
Added:
This is a suggestion how to perform a quick fix to your current problem, following the clarifications made in comments.
The following fields are being assumed:
• $Charges - Number[10]
• Sales Rep.|Distributor: - Text
• x2$Charges - Calculation[10] = [see formula below]
Change the calculation formula of x2$Charges to =
If ( Extend (Sales Rep.|Distributor: ) = "SSL" ; 1.5 ; 2 ) * ${$Charges}
There is no need for the x2CheckSSL field.
IMPORTANT:
You should not use repeating fields for this. I suggest that as soon as possible you rewrite your solution and fix the flaws dscovered here, namely:
Rename your fields to valid (and reasonable*) names ;
Convert repeating fields to records in a related table;
Use lookups instead of hard-coding data in calculations.
(*) e.g. not names that end with ":"
IF statement works exactly as you described and I do not see why you need two different functions. I do not understand your syntax - ${$Cost}. Are you trying to add "$" to your output?
Let's say you have a field for selection as "slelect_company" in Companies table/layout and you stored cost in a variable called $cost
You calculation will be:
If (Companies::slelect_company = "Comp4"; $Cost*1.5; $Cost*2 )
If you set the field to output result, use formatting to add $ sign
If you set the label on the layout to show the output, use this:
If (Companies::slelect_company = "Comp4"; "$" & $Cost*1.5; "$" & $Cost*2 )
If you have more than one check, you can use Case - similar to switch in the other languages
Rather than putting your calculation in a function try creating a new calculation field and put your calculation there. When the record is committed you will see the value of this calculation field change and you will know if your function is working.
To do this
Go to File->Manage->Database
Type in a new field name and select "calculation" as the type and press create.
Enter your calculation e.g. if(Companies::select_company = "Comp4"; Companies::Cost * 1.5; Companies::Cost * 2)
The calculation engine will tell you what the errors are when you try to press okay after typing the calculation.
If it never detects the condition "Comp4" then there is an error in your string comparison, perhaps a trailing space, or an uppercase character or similar.

Resources