Watson Assistant: How to remove unwanted characters from input string - regex

I am creating a chatbot where users need to input their phone. I need to be able to clean the user input string, removing any character that is not numeric. How can I do this in IBM Watson Assistant?

You can use the string functions like those with regular expressions to extract the phone number.
Another, maybe even better, option is to define a pattern-based entity type. The benefit would be that Watson Assistant could identify parts of the input as phone number entity and you could match dialog nodes or slots for it. If that is not found ("else") you could apply the extraction of numbers and try to guess if that is a phone number.

I would advise you handle user input at the client side. In your case, use the key-pressed event and an "If statement" to check that the character is a number (equal or greater than zero). Alternatively you can add the natural language understanding (Easy to configure machine learning service) to Watson Assistant to make it more intelligent. In this case, Watson will be able to know if data is a valid phone number or not.

Related

How to apply custom validation in vue-tel-input

As the title says, what is the process to applying a customValidate regex in vue-tel-input? You can see customValidate as the last item in the list of props. I have a standard setup like in this code sandbox. However, when I add a regex for the phone number to only allow a phone number with digits and a starting "+", the code hangs and kills my browser, customValidate: /^\+\d+$/. Is my formatting correct or is there another approach I should take? Is my regex ok?

Amazon Lex "slots" for alphanumeric values

I have simple ask, how do I create a Amazon Lex slot for Alphanumeric values.
So far I have tried -
AMAZON.Number: only takes decimal numbers
AMAZON.PostalAdress: takes
everything except numbers
Custom Slot with no values: Only numbers
Is there any way to create a slot which takes alphanumeric values?
Thanks
You can use a custom slot type.
Remember you don't need to enumerate all possible values, just provide enough training data so patterns match. Try giving it around 20-30 values and see if that's enough to train the slot type.
There is no particular datatype to take alphanumberic values.
AMAZON.NUMBER: accepts only numbers
AMAZON.US_FIRST_NAME: accepts only letters
As part of creating a chatbot in Amazon Lex, I have used AMAZON.Movie to accept both letters and numbers(alphanumberic values) it worked for me. As movie name can have alphanumberic values (Ex: The Incredibles2). I hope it works for you too.

What's the format of a CUID in SAP BI/BO?

I'm interfacing with an SAP BI/BO server and some webservices require an input id, called "CUID" (Cluser Unique ID). for example, there's a webservice getObjectById which reqires a cuid as input.
I'm trying to make my code more robust by checking if the cuid entered by a user makes sense, but I can't find a regular expression that properly describes how a CUID looks like. There is a lot of documentation for GUID, but they're not the same. Below are some examples of CUID's found in our system and it looks like they are well-formatted but I'm not sure:
AQA9CNo0cXNLt6sZp5Uc5P0
AXiYjXk_6cFEo.esdGgGy_w
AZKmxuHgAgRJiducy2fqmv0
ASSn7jfNPCFDm12sv3muJwU
AUmKm2AjdPRMl.b8rf5ILww
AaratKz7EDFIgZEeI06o8Fc
ATjdf_MjcR9Anm6DgSJzxJ8
AaYbXdzZ.8FGh5Lr1R1TRVM
Afda1n_SWgxKkvU8wl3mEBw
AaZBfzy_S8FBvQKY4h9Pj64
AcfqoHIzrSFCnhDLMH854Qc
AZkMAQWkGkZDoDrKhKH9pDU
AaVI1zfn8gRJqFUHCa64cjg
My guess would: start with capital A, then add 22 random characters in range [0-9A-Za-Z_.]. but perhaps it could be the A means something else and after awhile it would be using B...
Is anyone familiar with this type of id's and how they are formatted?
(quick side question: do I need to escape the "dot" in the square brackets like this \. to get the actual dot character?)
The definition of the different ID types and their purpose is described in the SAP KB note 1285103: What are the different types of IDs used in the BusinessObjects Enterprise repository?
However, I couldn't find any description of the format of the CUID. I wouldn't make any assumptions about it though, other than the fact that it's alphanumeric.
I did a quick query on a repository and found CUIDs consisting up to 35 characters and beginning with the letters A,B,C,F,k and M.
If you look at the repository database, more specifically the table CMS_INFOOBJECTS7, you'll notice that the column SI_CUID is defined as a VARCHAR2, 56 bytes in size (Oracle RDBMS).
Thus, a valid regex expression to match these would be [a-zA-Z0-9\._]+.

Insert and activate a phone number in a generated word document

I would like to add a phone number to a word document that I generate using the mso api.
In word, when one writes (Tel:00493298402938) and new line, the phone number is activated automatically.
While trying to record the corresponding macro and check the VBA code, it doesn't show the same behavior and the phone number is interpreted as a normal text.
Any helpful source code in VBA, C# or C++ is welcome.
Thanks!
Maybe the following code would be helpful to you?
ThisWorkbook.ActiveSheet.Hyperlinks.Add Range("A1"), "http://stackoverflow.com"
Just instead of the web address you would need the phone number.

Restrict users to enter numbers valid only till 2 decimal places C/C++

I am making an currency change program where I would be providing exact change to the input amount, for example a value of 23 would be one 20 dollars and 3 one dollar bills
I want to restrict the user to input the value only till 2 decimal places. For example: the valid inputs are
20, 20.4, 23.44 but an invalid input would be 20.523 or 20.000.
How can I do this is C/C++.
I read about one function that is setprecision but that is not what I want, setprecision allows to display the value till that decimal point, it still doesn't stop the user from entering any value.
Is there any way to do this?
Read the amount from the user as a string, either character by character or the entire line, and then check its format, and then convert it.
It's generally easier to let the user type whatever they want followed by the program rejecting the input if it isn't valid rather than restricting what they can type on a keystroke basis.
For keystroke analysis you would need a state machine with 4 states, which we can call Number, Numberdot, Numberdotone, and Numberdottwo. Your code would have to make the proper transitions for all keystrokes, including the arrow keys to move the cursor to some arbitrary place and the Backspace key. That's a lot of work.
With input validation, all you have to do is check the input using a regular expression, e.g. ^(([0-9]+) | ([0-9]+.[0-9]) | ([0-9]+.[0-9][0-9])$. This assumes that "20." is not valid. Then if it's invalid you tell the user and make them do it again.
I do not believe that there is any way to set the library to do this for you. Because of that you're going to have to do the work yourself.
There are may ways you can do this, but the only true way to handle restricting the input is to control reading it in yourself.
In this case you would loop on keyboard input, for ever keystroke you would have to decided if it can be accepted in the context of the past input, then display it. That is, if there is a decimal point you would only accept to more numbers. This also allows you to limit input to numbers and decimal places as well, not to mention input length.
The down side is you will have to handle all the editing commands. Even bare bones you would need to support delete and enter.
This is rather a task for the GUI you are using, than for core C/C++. Depending on your GUI/Web Toolkit you can give more or less detailed rules how data can or can not be entered.
If you are writing a normal GUI application you can control and modify the entered keys (in C or C++).
In a WEB application you can do similar things using javascript.
The best solution would be when all illegal input is impossible.