What is Amazon Lex inbuilt slot type for description or notes? - amazon-lex

I have configured my AWS Lex bot to 'Schedule A Meeting' and 'Add Notes' tasks.
While meeting scheduling I have a slot 'Meeting Description' where user can add single word to a sentence. Similarly for adding notes I have 'Notes'.
For this slot I am not finding any inbuilt slot type like 'AMAZON.Description' or anything which can store a word or a sentence. I tried with 'AMAZON.VideoGame', 'AMAZON.FoodEstablishment' etc. But found intermittent issue with those. Some times they work and some times they don't.
Does any body know what type of slot type I can use for my case? Please share.

You will want to use a Custom SlotType if you want to catch an input of anything.
When you "train" this SlotType by giving it values, you should include a wide variety, such as numbers, single letters, single words, phrases, and whole sentences.
Even that won't always catch what you want though. So even better than that, is to use your Lambda Function to parse and validate the entire input yourself. And most likely, just set your slot value to be the entire input string.
For example:
User: "Add to my notes"
Bot: "Ok, what would you like me to save in your notes?"
User: "Buy more toilet paper."
Now the user expects the entire phrase to be in the note. You will have to use utterances in your Custom SlotType like this:
I want to {note}
Go {note}
Buy {note}
{note}
Those utterances will sometimes leave out some words and in the example, place only "more toilet paper" without the "buy" as your slot value. This is why you will want to parse the entire input yourself. So in Lambda you can get the entire input from inputTranscript.
userInput = event.inputTranscript // "Buy more toilet paper"
slotNote = event.currentIntent.slots.note // "more toilet paper"
Then you can compare those two and do some fancy validation yourself, or just save the user input directly into the note slot.
userInput = event.inputTranscript // "Buy more toilet paper"
event.currentIntent.slots.note = userInput // overwrites note slot value with correct full user input.

Related

Is it safe to localize the "#" (pound sign, hashtag) as an ordinal indicator? (e.g. "#1", "#2")

We have a list of numbered reports that we display in our app - the numbering is important since the number of the report indicates the order it was created in, and gives the user a unique identifier to discuss the report with other users.
In a coworker's pull request, they're displaying text in labels in the UI for the cells which represent the reports with something like this:
label.text = "#\(report.userFacingNumber)"
This has the effect of numbering the reports correctly in english (i.e. "#1", "#2", etc) but I'm not sure that this will make sense in other languages.
Is the pound sign universal for indicating the ordinal of a list item? If not, is there an example language where this doesn't localize correctly that I could use to prove my point?
Is there a way in Swift/Foundation to correctly localize this ordinal listing?
"Is the pound sign universal for indicating the ordinal of a list item?"
No it is not. Many languages use N° or other symbols.
See:
https://en.wikipedia.org/wiki/Numero_sign
https://en.wikipedia.org/wiki/Number_sign#Usage_in_North_America
"Is there a way in Swift/Foundation to correctly localize this ordinal listing?"
Maybe there is a NumberFormatter that does this correctly, but I am not sure.
Your best bet is likely to omit the symbol.

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.

Validate User Inputted Text is Family-Friendly

I'm working on an iOS app that involves user input, and I'd like to keep it kid-friendly. One of the main features of the app is that user inputted titles and phrases can be shown to everyone who uses the app.
When a user creates a new title I want to verify that it is safe-for-work. My initial thought was just to have a list of all profane words and verify that none of them exist in the title:
for bad_word in list_of_bad_words:
if bad_word in user_inputted_title:
// Complain to user!
// Title is okay.
I imagine that there must be libraries or best practices for doing this. People could easily substitute numbers for letters, and I'm sure there are sequences of SFW words that create inappropriate phrases.
Can anyone suggest a better way of doing this? Specifically, if there are any Swift tools that would be awesome!
There are some cocoapods for this:
https://github.com/IslandOfDoom/IODProfanityFilter
https://github.com/MaxKramer/SCRProfanityChecker
I haven't used either of these personally, but I hope these can be a good starting point. The first one replaces any profanity with asterisks, and the second can give you the range of the profanity so you can replace it with your own filler. Good luck.

Explain the use of full-stop/period/point in a paragraph

I use COBOL in my business and I originally learned at a a site using perform - thru ....
Now I have changed jobs and the local programming standards are different, so I need to get used to PERFORM without THRU.
I also have a doubt about the use of the full-stop/period/point in a paragraph.
You can use the period to end sentences within a paragraph. I say this because I read in places that the paragraph ends with the first point, and elsewhere I see full-stop/period/point used differently to that.
I wrote two structures below which I understand should be equal. Is that so?
Structure A:
PERFORM 100-WRITING.
PERFORM 200-FINISH.
100-WRITING.
*-----------
DISPLAY "HI MY NAME IS FELIPE".
DISPLAY "THE WORLD IS GREAT".
DISPLAY "I DONT SPEAK ENGLISH".
200-FINISH.
*----------
DISPLAY "BYE BYE BABY".
DISPLAY "ESTO ES TODO".
Structure B:
PERFORM 100-WRITING.
PERFORM 200-FINISH.
100-WRITING.
*-----------
DISPLAY "HI MY NAME IS FELIPE"
DISPLAY "THE WORLD IS GREAT"
DISPLAY "I DONT SPEAK ENGLISH".
200-FINISH.
*----------
DISPLAY "BYE BYE BABY"
DISPLAY "ESTO ES TODO".
You are correct, the code you show is equivalent.
A paragraph or a SECTION must end with a full-stop/period/point. This means that the last thing (other than a comment or a blank line) in a paragraph or a SECTION must be a full-stop/period/point.
This does not mean that a full-stop/period/point actually ends a paragraph or SECTION. You are correct, a full-stop/period/point in a paragraph ends a sentence. A paragraph or SECTION must contain sentences only. Therefore a paragraph or SECTION must end with a full-stop/period/point because a sentence must end with one.
PERFORM 100-WRITING
PERFORM 200-FINISH
.
100-WRITING.
*-----------
DISPLAY "HI MY NAME IS FELIPE"
DISPLAY "THE WORLD IS GREAT"
DISPLAY "I DONT SPEAK ENGLISH"
.
200-FINISH.
*----------
DISPLAY "BYE BYE BABY"
DISPLAY "ESTO ES TODO"
.
Since the 1985 COBOL standard, sentences are no longer really important in COBOL in the PROCEDURE DIVISION, so it is only extra work if they are made important by the coder.
I find it much more convenient to re-write like the above. Don't attach the full-stop/period/point to anything. Just have it on in a line of its own. Then it means you can move around any of the lines in a paragraph/SECTION without worrying about whether the full-stop/period/point is in the correct place, because it is not actually attached to anything, so it never gets move around until you need it for the next paragraph/SECTION.
However, your site coding standards may not allow you to do this. You could always attempt to get them changed for the better :-)

iOS - Best way to get numbers out of NSString! (Geo coordinates)

For my internship I'm working on a App that uses GPS data! That's already implemented and I wrote a class which converts the double-value the mapView sends into an user-picked format for Geo Coordinates (Degrees, Degrees-Minutes or Degrees-Minutes-Seconds)! Now there are also text fields the user should enter some coordinates in for adding waypoints!
What's the best technique here to get a the seperate numbers out of a string in a format similar to this 57° 14' 03" N!
Since it's a user input, the format won't be this, it's only similar! So is it better to parse these out the string or maybe limit the users input method from a textfield to something more strict which only allows one format (separate textfields for each number f.ex.)!
Actually a question to UX rather than a how-to-do!
Acting as the delegate of the text field and not allowing invalid content / format is a good first step.
For parsing the string, NSScanner is the appropriate class to use to split out the parts. If you tie the format down though, you could use componentsSeparatedByString: to separate each number by the space between them.
First, a comment. Ending all your sentences with exclamation points is silly!
As to your question. Yes, you should enforce a strict input format on your users. If you look in the software developers's dictionary, user is a synonym for idiot.
I would suggest separate UITextFields for each numeric value of each lat/long, with the symbols drawn in place with labels. The user would enter degrees, and the input would jump to minutes. The user enters minutes, and the input jumps to seconds. The user enters seconds, and the input jumps to degrees on the longitude.
Validate each input as a well-formed number.
If you want to use free-form input of strings like "57° 14' 03" N!", you might want to create a regular expression to validate it, plus range-checking on the numeric parts. If you Google it you should find online docs on regular expression. I don't use them often enough to be able to write a regular expression off the top of my head.

Resources